我想将用户重定向到www.domain.com/index.php,如果他们输入:domain.com或www.domain.com。我对htaccess一无所知。这是我发现的,但我不知道如何为www编写OR语句。重定向
RewriteEngine on
RewriteCond %{HTTP_HOST} ^domain\.com
RewriteRule (.*) http://www.domain.com/index.php$1 [R=301]
答案 0 :(得分:1)
试试这个:
RewriteEngine on
RewriteCond %{HTTP_HOST} ^(www\.)?example\.com$
RewriteRule ^$ http://www.example.com/index.php [L,R=301]
答案 1 :(得分: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