.htaccess从URL删除&符? [英] .htaccess Removing ampersand from URL?
问题描述
很长一段时间以来,我一直在想办法解决掉我网站上某些URL的最后一部分的问题。例如,我想重写此:-
I have been banging my head against a wall for a long time trying to figure out how to get rid of the last part of some of the URL's on my site. For example, I would like to rewrite this:-
http://www.mysite.com/335-protective-wrapping&page=prod
为此
http://www.mysite.com/335-protective-wrapping
大约有2000个带有& page = prod的URL,我需要删除它们。这是URL的更多示例
There are about 2000 URL's with &page=prod at the end of them which I need to remove. Here's some more example URL's
http://www.mysite.com/335-protective-wrapping&page=prod
http://www.mysite.com/455-bubble-bags&page=prod
http://www.mysite.com/150-specialist-tapes&page=prod
我尝试了许多解决方案,但没有提出任何可行的方案。
I have tried many solutions but haven't come up with anything that works.
任何帮助将不胜感激。
谢谢。
Any help would be much appreciated. Thanks.
推荐答案
通过 httpd.conf $ c启用mod_rewrite和.htaccess $ c>,然后将此代码放在
DOCUMENT_ROOT
目录下的 .htaccess
中:
Enable mod_rewrite and .htaccess through httpd.conf
and then put this code in your .htaccess
under DOCUMENT_ROOT
directory:
Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteRule ^([^&]+)&page=prod$ /$1 [L,R=301]
这篇关于.htaccess从URL删除&符?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!