[英]Htaccess Redirect based on URL and query string
In my .htaccess I'm trying to redirect the following page: 在我的.htaccess文件中,我试图重定向以下页面:
/category/item?id=81 /类别/项目?ID = 81
To the following URL: 到以下URL:
/category /类别
This is where I got to far (it's at the top of my mod rewrites): 这是我的目标(这是我的mod重写的顶部):
RewriteCond %{REQUEST_URI} ^/category/item$
RewriteCond %{QUERY_STRING} ^id=81$
RewriteRule ^(.*)$ http://mywebsite/category? [L,R=301]
However it's not redirecting the page. 但是,它没有重定向页面。 Just wondering if there's anything I need to add to this to get it to work?
只是想知道是否需要添加任何内容才能使其正常工作?
Try it like this: 像这样尝试:
RewriteCond %{QUERY_STRING} ^id=81$ [NC]
RewriteRule ^category/item$ /category? [R=301,NE,NC,L]
or 要么
RewriteCond %{QUERY_STRING} ^id=81$ [NC]
RewriteRule ^category/item$ http://mywebsite//category? [R=301,NE,NC,L]
Use a fresh browser in incognito mode to test it. 在隐身模式下使用新的浏览器进行测试。
This did the trick for me (I solved it before the answers above were posted): 这对我有用(在发布以上答案之前,我已经解决了):
RewriteCond %{REQUEST_URI} ^/category/item$
RewriteCond %{QUERY_STRING} ^id=81
RewriteRule ^(.*)$ category? [L,R=301]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.