cortdev
asked on
.htaccess rewrite
Hello guys, I'm trying to redirect some pages which address are:
example.html?id=7
example.html?id=14
example.html?id=17
example.html?id=6
For some reason because the extension is .html the redirect does not work with the complete string so I redirected example.html to index.php and it worked but now here is the problem:
If you go to example.html?id=7 you get index.php?id=7 or
if you go to example.html?id=17 you get index.php?id=17.
My question is:
-How can I redirect example.html?id=7 to /example/address and make it work.
-If that is not possible how can I make example.html?id=7 go to index.php and loose all of the extra strings.
example.html?id=7
example.html?id=14
example.html?id=17
example.html?id=6
For some reason because the extension is .html the redirect does not work with the complete string so I redirected example.html to index.php and it worked but now here is the problem:
If you go to example.html?id=7 you get index.php?id=7 or
if you go to example.html?id=17 you get index.php?id=17.
My question is:
-How can I redirect example.html?id=7 to /example/address and make it work.
-If that is not possible how can I make example.html?id=7 go to index.php and loose all of the extra strings.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Ok after looking again the below should and i have tested it on my site redirect whatever id to index.php?=whateverid
RewriteCond %{QUERY_STRING} ^id=([0-9]+)
RewriteRule (.*) http://www.yourdomain.com/index.php?=id%1 [R=301]
Or here's a little shortcut to be placed on index.php
As you said:
If you go to example.html?id=7 you get index.php?id=7
or
if you go to example.html?id=17 you get index.php?id=17
Codes below ...
As you said:
If you go to example.html?id=7 you get index.php?id=7
or
if you go to example.html?id=17 you get index.php?id=17
Codes below ...
<?php
// put on index.php
if ( isset($_GET['id']) ) {
header("Location: index.php");
exit;
}
?>
Ian
Open in new window