简体   繁体   English

重定向无法通过mod_rewrite工作

[英]Redirect does not work through mod_rewrite

Why does not work this regex? 为什么此正则表达式不起作用? The general problem appears after simbol "?", Probable several options, but could not solve the problem. 一般问题出现在simbol“?”之后,可能有几个选项,但不能解决问题。

RewriteEngine on
RewriteRule ^portfolio.php?id=(.*?)$ /index.php?page_id=$1

You cannot match query string in RewriteRule pattern, that is used for matching REQUEST_URI only. 您不能以RewriteRule模式匹配查询字符串,该模式仅用于匹配REQUEST_URI You will need a RewriteCond for that. 为此,您将需要一个RewriteCond Use this rule: 使用以下规则:

RewriteEngine on

RewriteCond %{QUERY_STRING} ^id=([^&]*) [NC]
RewriteRule ^portfolio\.php$ /index.php?page_id=%1 [L,QSA]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM