I want to redirect index.php?action=this&id=1 to index.php?action=this&id=2
I tried the code below in my .htaccess but it didn't help
redirect 301 index.php?action=this&id=1 http://mysite.com/index.php?action=this&id=2
What am i doing wrong here? what could be a workaround?
In order to match specific query string you have to use mod_rewrite. Please check if it is installed/allowed on your host. The rule in this case will be something like this:
# most likely be required for rewrite rules to function properly
Options +FollowSymLinks +SymLinksIfOwnerMatch
# Activate Rewrite Engine
RewriteEngine On
RewriteBase /
# actual rule
RewriteCond %{QUERY_STRING} ^action=this&id=1 [NC]
RewriteRule ^index\.php$ /index.php?action=this&id=2 [R=301,L]
This needs to be placed in .htaccess in website root folder. If placed anywhere else some small changes may be required.
This rule will only redirect /index.php?action=this&id=1 to /index.php?action=this&id=2 and no other URLs (just as you asked in your question).
You could try just adding this on the page that you want redirected
<meta HTTP-EQUIV="REFRESH" content="0; url=index?action=this&id=2">
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With