Best way to 301 redirect 600 URL's back to the homepage?

efeezy

New member
Oct 5, 2007
5,250
136
0
50
I've got 600+ url's that I need to 301 back to the homepage. Is there a quick and easy way to do this, possibly with an .htaccess mod? Thanks.

Oh, and I have all of the URL's in a spreadsheet, so they're easy to access, cut, chop, paste whatever needs to be done.
 


What's the url structure like? Same domain? same path? Are there any urls on the same vhost that should not be redirected back to the homepage?

Give me a sample of the urls, (replace the domains with something generic) and I'll try to hack together a rewrite script (you're mentioning .htaccess, so I assume the pages are hosted with Apache).
 
If you can find a common pattern between these URLs, it should be easy to redirect all to home page with 1-2 simple regex rules. Otherwise you might have to go for one of these options.

1. All missing files are handled by a single file:
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /missing.php [L]

The missing.php can check whether the URL is one of your 600 URLs.

2. You have individual redirects from all of these URLs.
 
Many ways to accomplish this. If the 600 URLs are all hitting the same script (example: filename.php?pageId=600 ), you can simply put up a 301 redirect on that page that will redirect to the home page.

jitendraag has it covered, though, with the mod_rewrite rule posted above. That would likely be the easiest solution for you to go about.