We need to redirect a URL to a new URL but we can't get it to work and I believe it is due to the inclusion of variables in the URL.
For example, we need to redirect http://www.domain.com/attorneydetail...tion=view&id=8 to http://www.domain.com/practiceareas....tion=view&id=2
How would we do this in a .htaccess file?
301 redirect with PHP variables in URL
Moderator: General Moderators
-
curseofthe8ball
- Forum Commoner
- Posts: 73
- Joined: Sun Jun 01, 2003 12:33 am
Re: 301 redirect with PHP variables in URL
Try
REDIRECT 301 /attorneydetail...tion=view&id=8 http://www.domain.com/practiceareas....tion=view&id=2
Make sure you have a single space between the elements and dont include a http://www.domain.com in the first part where you tell which page to redirect.
REDIRECT 301 /attorneydetail...tion=view&id=8 http://www.domain.com/practiceareas....tion=view&id=2
Make sure you have a single space between the elements and dont include a http://www.domain.com in the first part where you tell which page to redirect.
-
curseofthe8ball
- Forum Commoner
- Posts: 73
- Joined: Sun Jun 01, 2003 12:33 am
Re: 301 redirect with PHP variables in URL
divedj,
Thanks for the reply. Unfortunately that doesn't seem to work. It works fine if I make it:
REDIRECT 301 /attorneydetails.php http://www.domain.com/practiceareas.php ... =view&id=2
But that isn't what we need. Something seems to get messed up when we pass the ?action=view&id=8 part in first URL element.
Thanks for the reply. Unfortunately that doesn't seem to work. It works fine if I make it:
REDIRECT 301 /attorneydetails.php http://www.domain.com/practiceareas.php ... =view&id=2
But that isn't what we need. Something seems to get messed up when we pass the ?action=view&id=8 part in first URL element.
Re: 301 redirect with PHP variables in URL
Sorry, just learned something myself.
The REDIRECT comand only looks at path/file not at querystrings of a given URL
you may have to look into modrewrite.
RewriteEngine on
RewriteCond %{QUERY_STRING} ^([^&]&)*id=8(&|$)
RewriteRule ^$ http://www.domain.com/attorneydetail...tion=view&id=2 [R=301,L,QSA]
A pretty good basic explanation of mode rewrite you find here http://www.yourhtmlsource.com/sitemanag ... iting.html
The REDIRECT comand only looks at path/file not at querystrings of a given URL
you may have to look into modrewrite.
RewriteEngine on
RewriteCond %{QUERY_STRING} ^([^&]&)*id=8(&|$)
RewriteRule ^$ http://www.domain.com/attorneydetail...tion=view&id=2 [R=301,L,QSA]
A pretty good basic explanation of mode rewrite you find here http://www.yourhtmlsource.com/sitemanag ... iting.html