Forum Moderators: phranque

Message Too Old, No Replies

RedirectMatch not working, what's wrong with it?

Redirect not working

         

nubbin

9:46 pm on May 10, 2004 (gmt 0)

10+ Year Member



Hi,

I've got a redirect in my Htaccess that isn't working and would be grateful if someone could let me know what's wrong with it:

# Redirect all files with a name that starts with file_49 to a new page

redirectMatch 301 /dir1/dir2/file_49*.htm [mysite.com...]

Thanks

gergoe

10:07 pm on May 10, 2004 (gmt 0)

10+ Year Member



the asterisk is a nice try, but you have to use regex patterns for the RedirectMatch also, just like for the mod_rewrite directives. check out the mod_alias documentation [httpd.apache.org] for more details.

Birdman

11:39 pm on May 10, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You could try putting the period before the asterisk(.*).

nubbin

2:13 am on May 11, 2004 (gmt 0)

10+ Year Member



Thanks guys. Using .* did the trick.

I knew I needed to use a regex but was misled by the regex guidelines I was following which said "* matches the preceding element zero or more times." It should have said .*

Thanks once again.

gergoe

10:17 am on May 11, 2004 (gmt 0)

10+ Year Member



it can be confusing indeed, but it is right;
* matches if the element (which can be anything; a single character, grouped expression, or the . which means anything) in your pattern just before the asterisk appears zero or more times in the test-string.
for example the .* matches on the "" (empty text), but also on the whole text i'm typing right now.