开发者

What is wrong with the mod-rewrite regex?

开发者 https://www.devze.com 2023-01-06 07:04 出处:网络
I am trying to rewrite tagged.php?flag=parameter&page=1 into /parameter/?page=1 So I am using: RewriteRule Hotties/?(.*)tagged.php?flag=parameter&page=$1

I am trying to rewrite

tagged.php?flag=parameter&page=1

into

/parameter/?page=1

So I am using:

RewriteRule Hotties/?(.*) tagged.php?flag=parameter&page=$1

However the result I am getting is:

/parameter/?page=

Which is the "1". I am not sure what is missing. Clearly the issue is with the (.) and the "=" but I am not sure what is wrong. I also tried (.$) which did not fi开发者_运维问答x it.


According to the documentation, you need to match against the URL path and the query string separately. If this is really your question,

I am trying to rewrite

tagged.php?flag=parameter&page=1

into

/parameter/?page=1

then you'd use

RewriteCond %{QUERY_STRING} flag=parameter&page=(\d+)
RewriteRule ^/tagged.php$ /parameter/?page=%1

but I suspect you actually want to go the other way around, in which case you'd use

RewriteCond %{QUERY_STRING} page=(\d+)
RewriteRule ^/parameter/$ /tagged.php?flag=parameter&page=%1

Not sure where the "Hotties" thing comes into it.

0

精彩评论

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