Simple htaccess RegEx

nterror

New Member
Messages
112
Reaction score
0
Points
0
This has got to be simple, but for some reason I'm running into problems. :nuts:

Trying to redirect links like the following:
Code:
http://mydomain.net/dirone/dirtwo/dirthree/etc/file

That match
Code:
/dirtwo/dirthree/

To
Code:
http://mydomain.net/page.htm
 
Last edited:

garrettroyce

Community Support
Community Support
Messages
5,611
Reaction score
249
Points
63
I think this is right:
Code:
RewriteRule ^/dirtwo/dirthree/.*$ page.htm [R,NC,L]

Rewrite URLs matching '/dirtwo/dirthree/' with any number of characters following, to page.htm, redirect, case insensitive, don't process any more rules.
 

nterror

New Member
Messages
112
Reaction score
0
Points
0
I must be tired or something, I was missing a period. :lol:

Works, thanks. :biggrin:
 

garrettroyce

Community Support
Community Support
Messages
5,611
Reaction score
249
Points
63
Glad it works. I was worried...I'm a little rusty on my htaccess regex ;)
 

vol7ron

New Member
Messages
434
Reaction score
0
Points
0
Not sure you need the ^, if you do you might need something like
^.*/dirtwo/dirthree/.*$ page.htm
 

garrettroyce

Community Support
Community Support
Messages
5,611
Reaction score
249
Points
63
Yeah, you probably don't need the url start (^) in there. The only problem is if you don't and you have something like:

/anotherdir/dirtwo/dirthree/... it will incorrectly match.
 
Top