我正在尝试从下面的URL进行301重定向
www.example.com/categories/Writing-Translation
到
www.example.com/categories/Writing-Translation-jobs
但是,它始终使用以下网址重定向页面
www.example.com/categories/categories/Writing-Translation-jobs?cid=Writing-Translation
这是用于重定向的htaccess代码
RewriteCond %{QUERY_STRING} ^cid=Writing-Translation$ [NC]
RewriteRule ^categories/Writing-Translation$ https://www.example.com/categories/Writing-Translation-jobs [R=301,NE,NC,L]
答案 0 :(得分:0)
您可以将此规则用作最高规则:
RewriteCond %{QUERY_STRING} ^cid=Writing-Translation$ [NC]
RewriteRule ^categories/Writing-Translation$ /categories/Writing-Translation-jobs? [R=301,NC,L]
目标URI末尾的 ?
将剥离现有查询字符串。确保在新的浏览器中对其进行测试。
答案 1 :(得分:0)
通过添加“ /?”来使用以下规则。在开始时:
RewriteRule ^ /?categories / Writing-Translation $ https://www.example.com/categories/Writing-Translation-jobs [L,R = 301]