htaccess 永久重定向到主页
htaccess permanent redirect to home page
我想在 htaccess 中写一条规则,总是将 http://example.com/index.aspx
或 http://www.example.com/index.aspx
重定向到 http://example.com
。
这是我目前尝试过的方法:
RewriteCond %{REQUEST_URI} ^/index.aspx [NC]
RewriteRule ^(.*)$ http://%1 [R=301,L]
但它无法正常工作。
谢谢
您只能使用一个规则:
RewriteRule ^index\.aspx$ http://%{HTTP_HOST} [NC,R=301,L]
我想在 htaccess 中写一条规则,总是将 http://example.com/index.aspx
或 http://www.example.com/index.aspx
重定向到 http://example.com
。
这是我目前尝试过的方法:
RewriteCond %{REQUEST_URI} ^/index.aspx [NC]
RewriteRule ^(.*)$ http://%1 [R=301,L]
但它无法正常工作。
谢谢
您只能使用一个规则:
RewriteRule ^index\.aspx$ http://%{HTTP_HOST} [NC,R=301,L]