D&C GLug - Home Page

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

Re: [LUG] htaccess regex question

 

On 8/19/07, Dave Morgan <morgadave@xxxxxxxxxxxxxx> wrote:
> My current .htaccess file -
>
> Redirect 301 /topmenu.html /topmenu.php
> Redirect 301 /books-az.html /books.php
> Redirect 301 /goodsinwards.html /gallery2/main.php/v/4801pics/
> Redirectmatch 410 ^(/gallery/)*
>
> The top three lines work,  but the bottom line does not.
>
> What should I have put on the bottom line to get it to match all
> paths starting /gallery/ ?

I would think -but haven't tested it- that
RedirectMatch 410 ^/gallery/.*
should work. (And quite probably you can leave out the .* as well.)

My big book on Apache is a few hundred miles from here, so I can't
check it now, but I think Apache directives are case-sensitive; hence
the capital 'M'. Moreover, the * in your regex means that it matches
the preceding block (i.e. "/gallery/" without the quotes) zero or more
times. Which, I think, it would always do.

It is, by the way, a very neat way of telling browsers and crawlers
that your page has been removed permanently. Just removing the
directory would give 404 errors, which would mean "I have no idea what
happened to these files, but I can't find them right now". Crawlers
are probably programmed to keep checking for quite a while in such
cases (and fair enough, you don't want your pages to be de-index just
because the moment the crawler visited your site, you had accidentally
removed a file).
http://www.checkupdown.com/status/E410.html

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