2010-05-15 5 views
0

domain.com 또는 www.domain을 입력하면 사용자를 www.domain.com/index.php로 리디렉션하고 싶습니다. com. 나는 htaccess에 대해 단서가 없다. 여기에 내가 찾은 것이 있지만 www에 대한 OR 문을 쓰는 방법을 모르겠습니다.htaccess reddom * .domain.com to www.domain.com/index.php

RewriteEngine on 
RewriteCond %{HTTP_HOST} ^domain\.com 
RewriteRule (.*) http://www.domain.com/index.php$1 [R=301] 
+1

당신은 여러한다 RewriteCond 규칙을 추가하고 마지막으로 모두의 끝에 추가 [OR] 수 있습니다. http://httpd.apache.org/docs/2.2/mod/mod_rewrite.html – Artefacto

답변

1

이 시도 리디렉션 :

RewriteEngine on 
RewriteCond %{HTTP_HOST} ^(www\.)?example\.com$ 
RewriteRule ^$ http://www.example.com/index.php [L,R=301] 
+0

그것은 작동합니다! 사용자가 domain.com/index.php를 입력 할 때 고려하지 않았으며 www.domain.com/index.php로 리디렉션되지 않습니다. – decimal

0
RewriteEngine on 
RewriteCond %{HTTP_HOST} ^(domain\.com)(:80)? [NC] 
RewriteRule ^(.*) http://www.domain.com/$1 [R=301,L] 
DirectoryIndex index.php  
order deny,allow 
+0

에서 매뉴얼을 읽는 것이 좋습니다. 원래 코드와 동일하게 작동합니다 (domain.com을 www.domain으로 리디렉션하지 않음). .com/index.php) – decimal