2012-10-04 4 views
0

가능한 중복 :
apache redirect from non www to wwwwww가 아닌 ​​www .htaccess 리디렉션이 작동하지 않습니까?

내가 내 도메인은 www가 버전에 www가 아닌 ​​리디렉션합니다. 어떤 이유로 아래 코드가 작동하지 않습니다.

제안 사항?

대부분의 쉬운 수정 프로그램이 있지만 작동시키지 못할 수 있습니다.

<ifmodule mod_deflate.c> 
<filesmatch \.(css|html|js|php|xml)$> 
    setoutputfilter deflate 
</filesmatch> 
</ifmodule> 
<ifmodule mod_security.c> 
secfilterengine off 
secfilterscanpost off 
</ifmodule> 

<ifmodule mod_rewrite.c> 
    RewriteEngine on 
RewriteCond %{HTTP_HOST} ^trailerpulse.com/ 
RewriteRule (.*) http://www.trailerpulse.com/$1 [R=301,L] 
RewriteCond %{request_filename} -f 
RewriteRule ^(.*) $1 [L] 
RewriteRule ^([a-z]+)(/([^/]{0,32})(/.+)?)?$ index.php?a=$1&q=$3 [L] 

</ifmodule> 
<ifmodule mod_expires.c> 
ExpiresActive On 
ExpiresDefault A0 
<filesmatch \.(css|js|gif|jpe?g|png)$> 
    ExpiresDefault A604800 
</filesmatch> 
<filesmatch \.(html|xml)$> 
    ExpiresDefault A10800 
</filesmatch> 
</ifmodule> 

FileEtag None 
Options All -Indexes 
ServerSignature Off 
ErrorDocument 404 /error 
+0

왜 당신이 그것을 위해 mod_rewrite를를 사용하는을? http://stackoverflow.com/questions/1100343/apache-redirect-from-non-www-to-www/1100363#1100363 –

+0

사이트가 기반으로하는 스크립트를 구입했을 때 작성된 코드입니다. – Rhys

+0

충분합니다. 링크 된 질문에서 언급 한대로'Redirect' 지시어를 사용하는 것이 좋습니다. 훨씬 간단합니다. –

답변

0

규칙이 거의 있습니다. 유일한 문제는 호스트 이름 다음에 슬래시가 있다는 것인데, 이 아니기 때문에은 요청의 "Host :"헤더에 나타납니다. $으로 /를 교체하고 케이스 무시하는 [NC] 플래그 추가

RewriteCond %{HTTP_HOST} ^trailerpulse.com$ [NC] 
RewriteRule (.*) http://www.trailerpulse.com/$1 [R=301,L] 
관련 문제