views:

16

answers:

1

I have the following URL:

http://somedomain.com/aa/search/search.php

I want it to return 2 selections, that of "aa" and that of "search/search.php".

With the help of Regex Coach, I have made the following regular expression which targets these two just fine:

/([a-z]{2})/(.*)

However, when I use them in my htaccess file, the rewrite just doesn't happen:

Options +FollowSymlinks
RewriteEngine on

RewriteRule /([a-z]{2})/(.*) /$2?var=$1

Can someone point this regex newbie in the right direction?

edit:

By "doesn't happen", I mean that following the URL: somedomain.com/aa/search.php gives me
"/aa/search.php not found"
rather than
"/search.php?var=aa not found".

+1  A: 

That depends on where you define the rule. Your syntax is correct for server (global) config files. If you use .htaccess files, the server will strip the path upto the place where the file is located from the URL. Try

([a-z]{2})/(.*)

(i.e. without the first slash)

Aaron Digulla
I am indeed using htaccess files... This solved my issue (in addition to adding ^ to the front)
Daniel