2011-05-06 3 views
-1

www.host.com 요청을 host.com으로 리디렉션하도록 요청하거나 .htaccess 파일에서 적절한 지시문을 host.com으로 리디렉션하도록 요청할 수 있습니까?www.host.com에서 .htaccess로 host.com으로 리디렉션

Options +FollowSymLinks 
RewriteEngine on 
RewriteCond %{HTTP_HOST} . 
RewriteCond %{HTTP_HOST} !^yoursite\.com 
RewriteRule (.*) http://yoursite.com/$1 [R=301, L] 

을 그리고 이것은 반대입니다 :

+1

@BusterX 환영합니다. 새 질문을 시작하기 전에 검색을 사용하십시오 :) http://stackoverflow.com/questions/4430617/how-to-redirect-www-url-to-non-www-url-with -htaccess – Prix

+0

및 http://stackoverflow.com/questions/1659949/how-to-change-htaccess-to-redirect-all-non-www-links-to-www-pages – Prix

+0

ServerFault에 속합니다. –

답변

2

http://www.yoursite.com에서 http://yoursite.com로 리디렉션됩니다

Options +FollowSymlinks 
RewriteEngine On 
RewriteCond %{http_host} ^yoursite.com [NC] 
RewriteRule ^(.*)$ http://www.yoursite.com/$1 [R=301,L] 

내가 내 서버에서 사용하는 것입니다, 그것은 완벽하게 작동합니다.

+0

이것이 작동하는지 확실하지 않습니다. 다른 하위 도메인을 사용하고 싶습니다. 예를 들어 test.yoursite.com은 동일하게 유지해야하며 www.yoursite.com 만 제거해야합니다. – BusterX