开发者

Apache Regex doesn't return first result

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 expres开发者_运维问答sion 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".


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)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜