开发者

mod_rewrite RewriteRule is not working

This is a follow-up of this question: Rewrite URL - how to get the hostname and the path?

I got this Rewrite Rule:

RewriteEngine On
RewriteRule ^(http://[-A-Za-z0-9+&@#/%=~_|!:,.;]*)/([-A-Za-z0-9+&@#/%=~_|!:,.;]*)\?([A-Za-z0-9+&@#/%=~_|!:,.;]*)$ http://http://www.xmldomain.com/bla/$2?$3&rtype=xslt&xsl=$1/$2.xsl

it seems to be correct, and exactly what I need. But it doesn't work on my server. I get a 404 page not found error.

mod_rewrite is enabled, as the following simple rule is working fine:

 RewriteEngine On
 RewriteRule ^page/([^/\.]+)/?$ index.php?page=$1 [L]

Can you 开发者_JS百科help?

Thanks


maybe try this

RewriteRule ^/(.+)/page/([^/]+)/(.*)$ domain/index.php?page=$2&host=%{HTTP_HOST} [QSA,NC,L]


It believe it's not correct. You cannot use a url as the first operand of RewriteRule.

What you should write instead of

RewriteRule ^(http://[-A-Za-z0-9+&@#/%=~_|!:,.;]*)/([-A-Za-z0-9+&@#/%=~_|!:,.;]*)\?([A-Za-z0-9+&@#/%=~_|!:,.;]*)$ http://http://www.xmldomain.com/bla/$2?$3&rtype=xslt&xsl=$1/$2.xsl

is (edit: for some reason you want to match the last portion path, I'll oblige)

RewriteCond %{HTTP_HOST} !=""
RewriteRule ^/(.*?)([^/]+)(?:/)?$ http://www.xmldomain.com/bla/page?rtype=xslt&xsl=http%3A%2F%2F%{HTTP_HOST}%2F$1$2.xsl%2A [QSA,B,P,NE]

Also note that rewrite rules are not automatically inherited by virtual hosts. You must activate inheritance explicitly.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜