问题
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