: Can mod_rewrite be used for this problem? We used to have a URL http://www.abc.com/index.php?itemID=144 which is moved to http://www.abc.com/index.php?itemID=1556 we want our users which are hitting
We used to have a URL
www.abc.com/index.php?itemID=144
which is moved to
www.abc.com/index.php?itemID=1556
we want our users which are hitting the above url(144) to reach to 1556. How can it be achieved. If with mod_rewrite or anything else.
More posts by @Becky754
1 Comments
Sorted by latest first Latest Oldest Best
Not sure if you want to redirect only 144=>1556 or it is just an example. Anyway you can try this:
Options +FollowSymlinks -MultiViews
RewriteEngine On
RewriteCond %{QUERY_STRING} (^|&)id=144(&|$) [NC]
RewriteRule ^(index.php)/?$ /?id=1556 [NC,R,L]
Explanation:
RewriteCond is making sure there is id=144 in query string
RewriteRule is making sure that request URI is index.php (optionally followed by a trailing slash).
If both conditions are satisfied then rule will redirect to /index.php?id=1556. (Note use of back reference instead of repeating index.php here).
Flags used are:
NC - ignore case comparison
R - redirect (by default with status = 302)
L - Mark it as last rule
If you really want to replace multiple old IDs to new IDs then I will suggest you to take a look at: httpd.apache.org/docs/current/mod/mod_rewrite.html#rewritemap
Terms of Use Create Support ticket Your support tickets Stock Market News! © vmapp.org2024 All Rights reserved.