我需要从http://example.com/重定向到http://example.com/index.php。
发布于 2012-04-16 22:16:20
使用以下命令:
DirectoryIndex index.php发布于 2012-04-16 22:16:33
试试这个:
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} ^$
RewriteCond %{HTTP_HOST} ^example.com$
RewriteRule ^$ http://example.com/index.php [L,R=301]发布于 2018-08-13 23:15:53
为了添加我自己的解决方案,由于the answer of Michael不适用于我,我做了如下操作:
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]这还会保留任何可能的现有查询字符串参数。
https://stackoverflow.com/questions/10175804
复制相似问题