I just can’t seem to be able to run a 301 redirect and rewrite when a specific variable is somewhere inside a dynamic URL.
For example, with any of these URLs:
/movabletype/mt-search.cgi?tag=SOMETHING&limit=20
/some-other-random-content?post=somethinghere&tag=SOMETHING
If tag=SOMETHING is anywhere inside the URL, then redirect to:
/categories/something_here/
Any ideas?! Here’s what I have so far – I’m at a loss as to what to put inside the RewriteCond
RewriteCond %{REQUEST_URI}
RewriteRule tag=SOMETHING /categories/something_here/ [L,R=301]
Your rewrite condition requires a left- and right-hand argument. It looks like you want to redirect when a certain URL parameter is present (i.e, tag), so you can use
%{QUERY_STRING}in your condition.Consider the following example:
This should take a URL like
/some-other-random-content?post=somethinghere&tag=SOMETHINGand redirect it to/categories/SOMETHING.URL Rewriting for Beginners may be a helpful guide.