.htaccess
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} !^/index\.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php [L]
通过此设置,/foo/bar
可以在漂亮的URL下访问页面,example.com/foo/bar
而丑陋的URLexample.com/index.php/foo/bar
仍然有效。我需要实现的是从永久重定向example.com/index.php/foo/bar
到example.com/foo/bar
。
RewriteRule .* index.php [R=301,L]
不起作用。
RewriteRule (.*) index.php/$1 [R=301,L]
完全相反,它从重定向example.com/foo/bar
到example.com/index.php/foo/bar
。请帮帮我!
像这样:
RewriteEngine On
RewriteBase /
# redirect rule to remove /index.php/ from start
RewriteRule ^index\.php(/.*)$ $1 [L,R=301,NC]
RewriteCond %{REQUEST_URI} !^/index\.php [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^ index.php [L]
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句