.htaccess 最简单的Htaccess,用于将index.php/html和非www重定向到www根目录

.htaccess 最简单的Htaccess,用于将index.php/html和非www重定向到www根目录,.htaccess,redirect,.htaccess,Redirect,使用.htaccess将index.php、index.html和非www变体重定向到www根目录的最简单方法是什么?例如重定向 http://example.com/index.php http://www.example.com/index.html http://example.com 到?它看起来不像是将index.html和index.php重定向到root?还是我错了?是的,会的。后面斜杠后面的$1反向链接到任何东西。啊,抱歉再看一遍,我明白你的意思了。如果您明确希望从特定页面重定

使用.htaccess将index.php、index.html和非www变体重定向到www根目录的最简单方法是什么?例如重定向

http://example.com/index.php
http://www.example.com/index.html
http://example.com

到?

它看起来不像是将index.html和index.php重定向到root?还是我错了?是的,会的。后面斜杠后面的$1反向链接到任何东西。啊,抱歉再看一遍,我明白你的意思了。如果您明确希望从特定页面重定向,则只需添加另一个
重写规则
。但是,如果
index.html
被设置为默认页面,那么这并不重要,它仍然会在相同的位置结束。
RewriteCond %{HTTP_HOST} ^example\.com [NC]
RewriteRule ^(.*)$ http://www.example.com/$1 [L,R=301]