Apache .htaccess 301 리디렉션은 서버측 리디렉션이며 영구 리디렉션입니다.
따라서 .htaccess 파일은 Apache 서버 구성 파일입니다. .htacces s 파일은 디렉토리별로 사용됩니다.
.htaccess 파일을 사용 하면 서버 성능이 저하됩니다. Apache 서버 기본 구성 파일인 httpd.conf에 액세스할 수 있는 경우 .htaccess 사용을 피해야 합니다. 공유 호스팅 웹사이트는 일반적으로 httpd.conf 파일에 액세스할 수 없으며 .htaccess 파일 을 사용해야 합니다.
이 301 리디렉션 응답은 페이지가 이전 URL에서 새 URL로 영구적으로 이동했음을 검색 엔진에 알립니다.
검색 엔진은 또한 이전 URL 페이지 순위를 새 URL로 전송합니다.
이 코드를 추가하거나 old-page.html 디렉토리에새 .htaccess 파일을 만듭니다.
old-page1.html에서 new-page.html로의 영구 리디렉션.
.htaccess:
Redirect 301 /old-page1.html http://www.mydomain.com/new-page1.html
모든 도메인 페이지에서 newdomain1.com으로의 영구 리디렉션.
.htaccess 파일은 이전 웹사이트의 루트 디렉토리에 있어야 합니다.
.htaccess:
Redirect 301 / http://www.newdomain1.com/
.htaccess 파일을 old-page.html 디렉토리에 업로드 했는데 리디렉션이 작동하지 않는 경우 일반적으로 .htaccess 파일이 Apache 서버 구성 파일 httpd.conf에서 활성화되지 않았음을 의미합니다.
.htaccess 파일 은 Apache 서버의 httpd.conf 파일을 추가하여 활성화할 수 있습니다.
httpd.conf:
<Directory /srv/www/rapidtable.com/public_html/web/dev/redirect>
AllowOverride All
</Directory>
중요: 이 설정은 Apache 서버 속도를 늦추기 때문에 권장되지 않습니다.
httpd.conf 파일을 변경할 수 있는 권한이 있는 경우 .htaccess 파일 대신 httpd.conf에 리디렉션 지시문을 추가하는 것이 좋습니다.
재작성 모듈의 라이브러리 mod_rewrite.so가 Apache 서버에 의해 로드되었는지 확인합니다.
$ apache2ctl -M
httpd.conf 파일에 다음 코드를 추가합니다.
재작성 모듈의 라이브러리 mod_rewrite.so를 사용할 수 없는 경우 첫 번째 줄의 주석을 제거하여 재작성 모듈을 로드합니다.
httpd.conf:
# LoadModule rewrite_module /usr/lib/apache2/modules/mod_rewrite.so
<Directory /srv/www/rapidtable.com/public_html/web/dev/redirect>
Redirect 301 /old-page.html http://www.mydomain.com/new-page.html
</Directory>
httpd.conf 업데이트 후 Apache 서버를 다시 시작하는 것을 잊지 마십시오.
$ sudo /etc/init.d/apache2 restart
Advertising