mod_rewrite regex help

Posted by Bathan on Stack Overflow See other posts from Stack Overflow or by Bathan
Published on 2010-05-17T17:36:42Z Indexed on 2010/05/17 17:40 UTC
Read the original article Hit count: 336

Filed under:
|

HI guys.

Im using mod_rewrite to do some redirects on a web site.

I want to be able to do the following mySite.com/ -> Goto Home mySite.com/foo -> Goto redirect.php and redirect acordingly.

My redirect rule was

RewriteRule (^\w*$) redirect.php?url=$1 [NC]

But im oviously missing something because when I go tomySite.com/ I get sent to redirect.php

I need a regex that allow lower and upper case letters, as well as underscores but it has to ignore "empty" strings so when I go to mySite.com/ the index file is displayed.

Any help?

Thanks!

© Stack Overflow or respective owner

Related posts about mod-rewrite

Related posts about regex