Forum Topic: Redirecting/Denying based on url string

Forum: .htaccess Forum : Redirecting • Posted by Bill Joseph • Updated:

I have a large number of inbound links to folders that have the name of a guy who used to work for my client a long time ago. Both he and the folders are gone now, but the links remain and are generating a lot of 404 errors. I was thinking I should redirect them to the home page, like this:

RedirectMatch 301 /joeblow/

but it’s not really a case of the urls moving. They simply don’t exist anymore and haven’t for years. Would there be any negative effect on my client if I were to do it this way?

(I thought about using HTTP_REFERER like this:

RewriteCond %{HTTP_REFERER} ^http://(www\.)?.*/joeblow/.*$ [NC]
RewriteRule .* [F,L]

but when I added that I got a 403 error regardless of the url.)

3 Replies to “Redirecting/Denying based on url string”

Posted by Jeff Starr

Using 301 redirect is certainly one way of doing it. You could also use a 410 “Gone” status code, which may be more accurate.

Using the referrer would mean that only requests coming *from* the nonexistent pages would be redirected, which doesn’t make sense.

If the content isn’t there, I would go with 410 or 301, depending on your SEO strategy and general preferences.

Posted by Bill Joseph •

Thanks, Jeff!

I guess I was (obviously) a little confused by HTTP_REFERER. I think using 410 would be the better option. So, I just need to swap out 410 for 301 in the RedirectMatch, right?

RedirectMatch 410 /joeblow/

Posted by Jeff Starr

Actually, there is no redirect involved with 410, so it would be just like this:

RedirectMatch 410 /joeblow/