Reputation: 2201
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?
Upvotes: 3
Views: 2921
Reputation: 165148
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).
Upvotes: 2
Reputation: 383
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">
Upvotes: 2
Reputation: 2640
just add the forward slash before the first url like
Redirect 301 /index.php?action=this&id=1 http://mysite.com/index.php?action=this&id=2
Upvotes: 1