2012-05-25 4 views
0

다음 .htaccess 코드를 사용 중입니다. 루트 폴더에서브 디렉토리에 htaccess www가 아닌 ​​www가 작동하지 않음

htaccess로는

#for redirecting www to non-www 
RewriteCond %{HTTP_HOST} ^www\.(.*) 
RewriteRule (.*) http://%1/$1 [R=301,L] 

#temporary redirect root to dir/ 
RedirectMatch ^/$ /dir/ 

현재 코드 www.domain.com으로 디렉토리 폴더

RewriteEngine on 
#for changing index file to a custom one 
DirectoryIndex abc.php?tag=ho 

#for simple url 
RewriteRule ^what/([^/]*)\.html$ /dir/abc.php?tag=$1 [L] 

에서 htaccess로는 domain.com하지만 www.domain.com/dir/로 리디렉션 리디렉션하지 않습니다.

  • 리디렉션 domain.com이 친절하게 안내

  • 을 domain.com/dir/ 비 WWWW에

    1. 리디렉션 WWW :

      나는 두 가지를 수정해야합니다.

    답변

    1

    리디렉션 (일치)과 rewriterule을 결합하면 문제가 발생합니다. RedirectMatch 대신 다음을 사용하십시오 :

    RewriteCond $1 !^dir/ 
    RewriteRule ^(.*)$ /dir/$1 [R=301,L] 
    
    +0

    +1 mod_alias와 mod_rewrite를 섞지 않는 것이 좋습니다. – anubhava

    관련 문제