开发者

.htaccess passing domain name

I am trying to Rewrite path in .htaccess

=-=-=-=-=-EDIT=-=-=

Hi I may not have expressed my problem clearly. So here's a live example of my problem.

"http://fames.in/site/bollywoodhungama.com" - works fine
"http://fames.in/site/bollywoodhungama.com/2" - error

The format of the url is:

http://fames.in/site/(site name)/(page number)

I use the following codes in .htaccess

RewriteRule ^site/(.*)$ sitelist.php?q=$1&page=1
RewriteRule ^site/(.*)/([0-9]+)$ sitelist.php?q=$1&page=$2

the first line works fine. In the second line of the code htaccess passess the whole parameters to 'q'.开发者_开发问答 taking above url it is passed as "/sitelist.php?q=bollywoodhungama.com/2" . I need it to pass the 'q' and 'page' separately. Like "/sitelist.php?q=bollywoodhungama.com&page=2"


The problem is that the first rule is always matching. The .* is greedy so the /2 is part of the match. What you need is the change the match to 'anything but slash' like so:

RewriteRule ^site/([^/]*)$ sitelist.php?q=$1&page=1

So the second domain will fail to match, and then the second rule will match.

Not sue if you need more rules applied after this rule of not, but you may want to add 'last rule flag' [L] to the end of you rule.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜