Mod_Rewrite wildcard's / appending

China☆狼群 提交于 2020-01-06 14:55:22

问题


I'm trying to make a global rule with a category on my website where something automatically gets added to the end of url.

An example:

www.websitename.com/category/page.html gets changed to www.websitename.com/category/page.html?somethingelse and anything subsequently which is www.websitename.com/category/* gets appended with ?somethingelse

I know I could do this with individual 301 redirects but is there a one rule fits all? as every time a new page is created currently, a new redirect would have to be made.


回答1:


If I'm understanding you correctly, this should do the trick:

RewriteRule ^category/(.*.html)$ category/$1?somethingelse

This means that every URL that starts with category and ends with html will be rewritten to add ?somethingelse at the end. Examples:

http://www.websitename.com/category/foo.html => http://www.websitename.com/category/foo.html?somethingelse
http://www.websitename.com/category/bar.html => http://www.websitename.com/category/bar.html?somethingelse


来源:https://stackoverflow.com/questions/11470373/mod-rewrite-wildcards-appending

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!