.htaccess problem

Posted by londonhogfan, 09-23-2008, 02:05 AM
hi, I'm having quite a problem with my site on google. I rushed into things and have had to restructure the site so now I have a lot of missing pages on google. I am trying to forward all the bad pages to the correct ones, but there are a few hundred. Is there an easier way than doing what I'm doing? Redirect 301 /db/coaching-results/1/John-Clinton-Futrall/CoachDetails.php?coach=15 mydomaincom/coaching-records/1/John-Clinton-Futrall/ Redirect 301 /db/coaching-results/1/John-Clinton-Futrall/CoachDetails.php?coach=23 mydomaincom/coaching-records/1/John-Clinton-Futrall/ Redirect 301 /db/coaching-results/1/John-Clinton-Futrall/CoachDetails.php?coach=24 mydomaincom/coaching-records/1/John-Clinton-Futrall/ Redirect 301 /db/coaching-results/1/John-Clinton-Futrall/CoachDetails.php?coach=25 mydomaincom/coaching-records/1/John-Clinton-Futrall/ Redirect 301 /db/coaching-results/1/John-Clinton-Futrall/CoachDetails.php?coach=29 mydomaincom/coaching-records/1/John-Clinton-Futrall/ Redirect 301 /db/coaching-results/1/John-Clinton-Futrall/CoachingResults.php mydomaincom/coaching-records/1/John-Clinton-Futrall/ Redirect 301 /db/coaching-results/1/John-Clinton-Futrall/GameSearch.php mydomaincom/coaching-records/1/John-Clinton-Futrall/ Redirect 301 /db/coaching-results/1/John-Clinton-Futrall/Opponents.php mydomaincom/coaching-records/1/John-Clinton-Futrall/ Redirect 301 /db/coaching-results/1/John-Clinton-Futrall/Players.php mydomaincom/coaching-records/1/John-Clinton-Futrall/ Redirect 301 /db/coaching-results/1/John-Clinton-Futrall/Polls.php mydomaincom/coaching-records/1/John-Clinton-Futrall/ Redirect 301 /db/coaching-results/1/John-Clinton-Futrall/YearlyResults.php mydomaincom/coaching-records/1/John-Clinton-Futrall/ basically I had some links coming after "John-Clinton-Futrall" on the template and it has added it for many, many pages. I need to change all directories from "coaching-results" to "coaching-records" and then remove anything coming after the "/" following "Futrall" Thanks for any help.

Posted by Jatinder, 09-23-2008, 02:43 AM
Try this:

Posted by londonhogfan, 09-23-2008, 09:25 AM
thanks for this. does this do a 301 redirect? Is it possible to make it work where the "1" and "john-clinton-Futrall" changes. example... there is a /3/different-name/, /4/another-name/, etc so anytime the site has db/coaching-results/#/aaa-bbb-ccc/~ it should redirect to db/coaching-records/#/aaa-bbb/ccc/ Thanks for your time.

Posted by foobic, 09-23-2008, 07:27 PM
It would be a 302 by default. Here's a tweaked version:

Posted by londonhogfan, 09-23-2008, 08:19 PM
thats working much better. My only problem now is that is still leaves the "?coach=15" or anything after ".php" thanks for helping me out on this.

Posted by foobic, 09-23-2008, 08:34 PM
No problem. A final ? should clear the query string:

Posted by londonhogfan, 09-23-2008, 09:03 PM
perfect! Thanks again.

Posted by mod_webhosting, 09-24-2008, 07:13 AM
Because of the how regular expression works, more efficient way would be: Both RewriteRules do the same redirection. Benchmark: 10000 foobic's regular expression matchings: 0.117690086365 seconds 10000 my regular expression matchings: 0.0283961296082 seconds You'll be fine with either one you choose and you'll notice no speed difference. I'm just pointing out that efficiency should also be kept in mind while programming.

Was this answer helpful?

 Print this Article

Also Read

sdb instead of sda -> Help needed

Posted by CoolMike, 07-17-2007, 03:23 AMHi I have a server with a raid5 configuration. Linux...

Mysql query LIKE%

Posted by net4all, 03-12-2010, 05:32 AMI got a special mysql-problem: I have a table containing...

Need PHP5 Developer for open source web game project

Posted by openwars, 01-16-2008, 04:54 PMHello hxxp://sf.net/projects/modulargaming is our...

kernel exploit!

Posted by tkanaco, 06-27-2008, 11:27 PMHow Can i translate An Kernel Exploit to secure my server...

httpd optimization.

Posted by NWSTech, 04-22-2009, 09:57 AMevening all, right ive got a server thats getting...