Reputation: 10609
I've got a URL with a query string that I am trying to redirect and I just can't get it to work. The original URL not only has a query string, it's a Joomla SEF URL and contains a ? within the URL as well. It's a mess. This is the original URL:
I've tried several different rewrite conditions and rules and none I have tried are working. I am also putting the statements in .htaccess in the root since there are no actual sub directories. The query string does not need to transfer.
I tried this and it didn't work:
RewriteCond %{REQUEST_URI} ^/menu-item/item/1234-article-title-here\?\.html$
RewriteRule ^(.*)$ http://www.domain.com/new-page.html? [R=302,L]
I also tried
RewriteCond %{REQUEST_URI} ^/menu-item/item/1234-article-title-here$
RewriteRule ^(.*)$ http://www.domain.com/new-page.html? [R=302,L]
And this
RewriteCond %{REQUEST_URI} ^1234-article-title-here\?\.html$
RewriteRule ^(.*)$ http://www.domain.com/new-page.html? [R=302,L]
and this
RewriteCond %{REQUEST_URI} ^1234-article-title-here$
RewriteRule ^(.*)$ http://www.domain.com/new-page.html? [R=302,L]
As well as the answer from @jon lin. I ended up finding a redirect that worked, posted below.
Upvotes: 1
Views: 1061
Reputation: 10609
This is what finally ended up working:
RewriteCond %{REQUEST_URI} ^/menu-item/item/1234-article-title-here$
RewriteRule ^(.*)$ http://www.domain.com/new-page.html? [R=302,L]
Upvotes: 1
Reputation: 143866
Have you tried:
RewriteEngine On
RewriteCond %{QUERY_STRING} ^\.html&utm_source=XYZ&utm_medium=ABC&utm_campaign=the+campaign+name$
RewriteRule ^menu-item/item/1234-article-title-here$ /page-you-want-to-redirect-to? [L,R=301]
The ?
at the end of the target removes the query string so that it doesn't get included in the redirect.
Upvotes: 0