lukep11a Posted March 4, 2012 Share Posted March 4, 2012 Hi, I had a page, team-info.php?team_id=48 for example and some of these pages have been indexed by google, I then decided to move team-info.php into a folder named team and use my .htaccess file to rewrite the links to team/48 meaning some of the results in google now link to an error page. I have tried to direct the old links to the new links but it doesn't seem to be working, here's my code: Rewrite rule that currently works to point dynamic link to a clean URL: RewriteRule ^team/([0-9]+)$ team/team-info.php?team_id=$1 Rewrite rule to move the old dynamic link to the new one, that is not currently working: RewriteRule ^team-info.php?team_id=([0-9]+)$ team/$1 [R=301,L] If anyone can help me on this then I would be very grateful, i've been trying different solutions out for a while now and not getting anywhere, thanks. Link to comment https://forums.phpfreaks.com/topic/258253-permanently-moved-page-help/ Share on other sites More sharing options...
S3cr3t Posted March 4, 2012 Share Posted March 4, 2012 Tried that one ? RewriteRule ^team-info.php?team_id=([0-9]+)$ team/team-info.php?team_id=$1 [R=301,L] Link to comment https://forums.phpfreaks.com/topic/258253-permanently-moved-page-help/#findComment-1323801 Share on other sites More sharing options...
lukep11a Posted March 4, 2012 Author Share Posted March 4, 2012 Yeah that doesn't work either, takes me to the 404 Error page Link to comment https://forums.phpfreaks.com/topic/258253-permanently-moved-page-help/#findComment-1323818 Share on other sites More sharing options...
kicken Posted March 4, 2012 Share Posted March 4, 2012 The path used by RewriteRule does not include the query string. You have to test that in a RewriteCond directive. RewriteCond %{QUERY_STRING} team_id=([0-9]+) RewriteRule ^team-info.php$ team/%1 [R=301,L] I believe that would be what you want. Link to comment https://forums.phpfreaks.com/topic/258253-permanently-moved-page-help/#findComment-1323860 Share on other sites More sharing options...
lukep11a Posted March 4, 2012 Author Share Posted March 4, 2012 Hi, thanks for your reply, your suggestion displays the correct page, but the URL however is quite right, it is displaying it like this: http://www.mysite.com/team/48?team_id=48 instead of like this: http://www.mysite.com/team/48 Any ideas why this could be? Link to comment https://forums.phpfreaks.com/topic/258253-permanently-moved-page-help/#findComment-1323871 Share on other sites More sharing options...
kicken Posted March 4, 2012 Share Posted March 4, 2012 RewriteCond %{QUERY_STRING} team_id=([0-9]+) RewriteRule ^team-info.php$ team/%1? [R=301,L] Try that. Link to comment https://forums.phpfreaks.com/topic/258253-permanently-moved-page-help/#findComment-1323876 Share on other sites More sharing options...
lukep11a Posted March 4, 2012 Author Share Posted March 4, 2012 Thanks, that works perfectly!! Link to comment https://forums.phpfreaks.com/topic/258253-permanently-moved-page-help/#findComment-1323879 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.