We currently have: postp154336.html&highlight= However, we want to redirect them to just postp154336.html Please be aware that the URLs are changing, for example postp12345.html - the bold can change. Thank you for your help.
We also want to remove: postt10093.html&view=next postt10093.html&view=previous However, we only want to remove those strings, not ALL strings from the end of the URLs. Thank you.
Something like this should do it: RewriteCond %{QUERY_STRING} ^highlight=$ RewriteRule ^postp([0-9]+)\.html$ /postp$1.html? [R=301,L] RewriteCond %{QUERY_STRING} ^(.*&?)(view=(next|previous))&?(.*)$ RewriteRule ^postt([0-9]+)\.html$ /postt$1.html?%1%4 [R=301,L] Code (markup):
Thank you for your reply. Unfortunately, that didn't work. To make things even more complicated, the actual postt10093.html is a RewriteRule itself using this rule: RewriteRule ^post(p|t)([1-9][0-9]*).html$ modules.php?name=Forums&file=viewtopic&$1=$2 Code (markup): Would this make a difference? Thank you again.
It should work if you put my rules before it. Make sure it has the [QSA] flag at the end of that last one though so it sends any additional query strings. Something like: RewriteCond %{QUERY_STRING} ^highlight=$ RewriteRule ^postp([0-9]+)\.html$ /postp$1.html? [R=301,L] RewriteCond %{QUERY_STRING} ^(.*&?)(view=(next|previous))&?(.*)$ RewriteRule ^postt([0-9]+)\.html$ /postt$1.html?%1%4 [R=301,L] RewriteRule ^post(p|t)([1-9][0-9]*).html$ modules.php?name=Forums&file=viewtopic&$1=$2 [L,QSA] Code (markup):
Thank you for your reply. It's still not working and just returning a 404. I have placed your RewriteRules before the existing one, I have appended the QSA, I have even removed the $ from the original RewriteRule, which fixes the 404 of course, but still does not redirect to the page with the stripped query string. I'm lost - any ideas? Thank you again.