![](/img/trans.png)
[英].htaccess in root and subfolder, each to redirect to own index.php
[英].htaccess redirect root to index.php
我需要从http://example.com/
重定向到http://example.com/index.php
。
用这个:
DirectoryIndex index.php
试试这个:
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} ^$
RewriteCond %{HTTP_HOST} ^example.com$
RewriteRule ^$ http://example.com/index.php [L,R=301]
只是为了添加我自己的解决方案,因为迈克尔的答案对我不起作用,我做了类似的事情:
RewriteEngine on
# These two lines redirect non-www to www.
RewriteCond %{HTTP_HOST} ^example\.com$
RewriteRule (.*) https://www.example.com$1 [R=301,L]
# These two lines redirect the root to index.html.
RewriteRule ^$ /index.html [R=301,L]
RewriteRule ^/$ /index.html [R=301,L]
这还保留了任何可能的现有查询字符串参数。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.