D&C GLug - Home Page

[ Date Index ] [ Thread Index ] [ <= Previous by date / thread ] [ Next by date / thread => ]

Re: [LUG] htaccess regex question

 

On 8/20/07, Dave Morgan <morgadave@xxxxxxxxxxxxxx> wrote:
> It turns out RedirectMatch 410 /gallery/* was all I needed. You
> are right that the web crawlers will never give up, even after
> many months' of 404's, And I want them to forget all about these
> old links.

I know it's annoying if, once you've solved your problem, someone
tells you he has an even better solution, so feel free to ignore what
I'll write below. :)

I would change the line to
  RedirectMatch 410 ^/gallery/
Right now, your server delivers a 410 error to all requests to
anything that contains a forward-slash, then the word gallery and then
zero or more forward-slashes. Which would also give the error to
/photos/gallery.php, something that someone might put on your site in
five years' time. The ^ makes sure the request uri should start with
/gallery, while a * in regexes is not a wildcard as in the command
line, but means "zero or more times the previous block/character" (so
zero or more slashes).

> <embarressed>
> the problem turned out to be that allowoverride was set to 'none'
> in my site config, so it was ignoring the .htaccess file :-/
> </embarressed>

Do you have access to the site config (i.e. the Apache config file)?
In that case, I would put the contents of the .htaccess file there
too. (Any HowTo on .htaccess will start by saying that you should
avoid using .htaccess as much as possible.)

> The only problem is that I am forced to put http://morgad.co.uk/
> at the start of all redirected addresses otherwise I get internal
> server errors

This is because you have to supply absolute URLs in Redirect(Match).
See http://httpd.apache.org/docs/2.0/mod/mod_alias.html#redirect

Martijn.

-- 
The Mailing List for the Devon & Cornwall LUG
http://mailman.dclug.org.uk/listinfo/list
FAQ: http://www.dcglug.org.uk/linux_adm/list-faq.html