开发者

How do I make an exception to a mod rewrite rule?

I absolutely do not understand mod rewrite or the syntax to make it work. I have however managed to cobble together the following, which works exactly as I need it to on my site:

RewriteRule ^page/([^/\.]+)/?$ 开发者_运维知识库page.php?page=$1 [L]

it changes www.mysite.com/one into www.mysite.com/page.php?page=one

wonderful.

However, is there a way that I can add an exception to the rule, so that if I try to use the url www.mysite.com/feed for example, it will go to www.mysite.com/feed/index.php rather than trying to redirect to www.mysite.com/page.php?page=feed

Thanks in advance!!


There are a couple of ways you could do this. Probably best would be to add a RewriteCond above the RewriteRule. Something like this (untested):

RewriteCond !^feed
RewriteRule ^page/([^/\.]+)/?$ page.php?page=$1 [L]

If you can't get that to work then you could also put a different RewriteRule above your one to redirect before this rule is matched...

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜