RewriteRule being greedy

Posted by lardlad on Stack Overflow See other posts from Stack Overflow or by lardlad
Published on 2010-04-20T11:21:32Z Indexed on 2010/04/20 11:23 UTC
Read the original article Hit count: 271

Filed under:
|

I have been looking for an answer for a few hours now, so sorry if this was asked a ton of times, I missed it.

I basically want to make a rewrite to ignore the first directory. That first dir in the path will be different so I thought I could use a regex. But my regex is matching all the way to the file name:

RewriteRule ^([a-z]+)?/(.+)$ $2 [L]

this works if I am one level deep:

http://test.domain.com/one/index.php

I get the actual index page of the root. Which is what I want. but if I were to go deeper:

http://test.domain.com/one/two/index.php

I get a message saying /index.php was not found. So it seems my regex is not stopping after the last [a-z]. I appreciate any help.

This is Apache2 if that matters at all.

© Stack Overflow or respective owner

Related posts about apache

Related posts about mod-rewrite