Forum Moderators: phranque
On an existing website we've changed the urls for SEO.
Now the urls look like this:
http://www.example.com/mainnavigation/subnavigation/title_of_the_page.html
The old situation looked like this:
http://www.example.com/?id=1 etc.
How do we redirect/rewrite (?) the old links to the new pages?
So http://www.example.com/?id=1 has to go to http://www.example.com/mainnavigation/subnavigation/title_of_the_page.html
NB: the destinationpage above is static!
This rule doesn't work:
Redirect 301 http://www.example.com/?id=1 http://www.example.com/mainnavigation/Aboutsubnavigation/title_of_the_page.html
We have the folowing rules in htaccess:
RewriteRule ^([^/\.]+)/([^/\.]+).html?$ index.php?idname=$1
RewriteRule ^([^/\.]+)/([^/\.]+)/?$ index.php?idname=$1&pagename=$2
RewriteRule ^([^/\.]+)/([^/\.]+)/([^/\.]+).html$ index.php?idname=$1&pagename=$2
[edited by: jdMorgan at 2:23 pm (utc) on Sep. 29, 2007]
[edit reason] example.com [/edit]
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /\?id=1\ HTTP/
RewriteRule ^$ http://example.site.com/mainnavigation/Aboutsubnavigation/title_of_the_page.ht[b]ml?[/b] [R=301,L]
THE_REQUEST is the entire client request header, which for example, might look like this:
GET /some-page.php?arg1=abc&arg2=def HTTP/1.1
The question mark at the end of the rewriterule substitution URL will clear the requested query string. It will not appear in the rewritten URL itself.
Jim