您好,我正在尝试重写我的网址
http://example.net/?r=123到这一个
http://example.net/ref/123在我的.htaccess中,使用下面的代码就可以了
RewriteEngine on
RewriteRule ^ref/([^/.]+)/?$ /index.php?r=$1 [R=301]但我想添加另一个重写规则。当链接像这样时:
http://example.net/?r=123我想将其重定向到:
http://example.net/我尝试了这个重写规则,但它不起作用:
RedirectMatch "^/?r=([^/.]+)" "/index.php"请帮帮忙。任何帮助都将不胜感激。非常感谢。
发布于 2015-12-24 06:50:17
尝试使用这些规则将查询字符串URL重定向到更常见的漂亮URL。基本上将旧的网址重定向到SEO友好的网址。
RewriteEngine on
RewriteCond %{THE_REQUEST} ^GET\ /+\?r=([^&\s]+)\
RewriteRule ^ /ref/%1? [R=302,L]
RewriteRule ^ref/([^/.]+)/?$ /index.php?r=$1 [R=301]如果您仍然希望将查询字符串重定向到index.php,请尝试以下规则
RewriteEngine on
RewriteCond %{THE_REQUEST} ^GET\ /+\?r=([^&\s]+)\
RewriteRule ^ /index.php [R=302,L]
RewriteRule ^ref/([^/.]+)/?$ /index.php?r=$1 [R=301]https://stackoverflow.com/questions/34444814
复制相似问题