2013-05-02 2 views
2

으로 리디렉션하는 방법 최근에 내 index.html을 index.php로 변경했습니다.이를 반영하기 위해 리디렉션을 수행하고 싶습니다. 다시 작성하면 foo.com/index.php가 foo.com/이되고 .php 파일에 액세스하게됩니다.index.html을 index.php로 리다이렉트하고 index.php를/

foo.com의 하위 디렉토리에있는 bar.com 사이트에도 영향을 미치지 않기를 바랍니다.

이 내가 리디렉션 순환에 어떤 결과 한 것입니다 :이 작업을 수행 할 수있는 방법이

RedirectMatch 301 ^/index.html?$ /index.php 
Options +FollowSymLinks 
RewriteEngine on 
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /.*index\.php\ HTTP/ 
RewriteRule ^(.*)index\.php$ /$1 [R=301,L] 

있습니까? 감사!

답변

5

RedirectMatch 지시어는/ 요청을 받아 다음은 다시 URL 파일 매핑 파이프 라인을 통해 넣어 얻을 따라서 귀하의 리디렉션 지시어와 일치 /index.html로 리디렉션 내부 리디렉션 후 일치합니다. 당신은을 포함하여 시도 할 수

A :

DirectoryIndex index.php 

이 자동 내부 리디렉션을 방지하기 위해. 당신이 index.php로하고있는 것처럼 당신은 또한 index.html 파일로 %{THE_REQUEST} 경기를 사용해야합니다

Options +FollowSymLinks 
DirectoryIndex index.php 

RewriteEngine on 

RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /.*index\.php\ HTTP/ 
RewriteRule ^(.*)index\.php$ /$1 [R=301,L] 

RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /.*index\.html\ HTTP/ 
RewriteRule ^(.*)index\.html$ /$1index.php [R=301,L] 

을 또는 당신은 index.php를 완전히 무시할 수 있습니다 : 절대적으로 아름다운

RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /.*index\.html\ HTTP/ 
RewriteRule ^(.*)index\.html$ /$1 [R=301,L] 
+1

합니다. 정확히 내가 원했던/필요로하는 것. 대단히 감사합니다! –