我在这样的菜单中有一个网址:
http://www.example.com/index.php?main_page=contact_us
我在.htaccess中使用以下内容将其转换为“干净”网址:
RewriteRule ^/?([^/d]+)/?$ index.php?main_page=$1 [L,QSA]
即使这行得通,因为使用http://www.example.com/contact_us可以进入联系人页面没有问题,实际上并不会改变原始链接。
所以现在我想我需要更改php菜单中的链接以使用干净的URL或使用更好的htaccess重写规则来自动执行此操作。我希望后者,有什么想法吗?
您可以插入此新规则来执行此重定向:
RewriteCond %{THE_REQUEST} \s/+index\.php\?main_page=([^\s&]+) [NC]
RewriteRule ^ /%1? [R=302,L,NE]
RewriteRule ^([^/.]+)/?$ index.php?main_page=$1 [L,QSA]
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句