Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/regex/20.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Regex .htaccess更改/匹配到&;_Regex_.htaccess - Fatal编程技术网

Regex .htaccess更改/匹配到&;

Regex .htaccess更改/匹配到&;,regex,.htaccess,Regex,.htaccess,我希望在我的页面上有以下URL: www.domain.com/<module>/<function>/<query>=<string>/<query>=<string>/<query>=<string> www.domain.com///=/=/= 我知道如何将模块和函数的部件与以下有效URL相匹配: www.domain.com/index.php?module=<module>&

我希望在我的页面上有以下URL:

www.domain.com/<module>/<function>/<query>=<string>/<query>=<string>/<query>=<string>
www.domain.com///=/=/=
我知道如何将模块和函数的部件与以下有效URL相匹配:

www.domain.com/index.php?module=<module>&function=<function>
www.domain.com/index.php?模块=&function=
但我不知道如何将所有那些query=string参数附加到查询字符串中

我目前使用
RewriteRule^([A-Za-z0-9_239;]+)/([A-Za-z0-9_239;]+)$index.php?模块=$1和函数=$2[NC]
作为我的规则,并希望添加这些(可选和可重复的)查询字符串部分


我希望有人比我更了解htaccess和regexp xD

这些规则需要放在网站根文件夹的.htaccess文件中

RewriteRule ^(.+)/([a-z0-9_]+)=([^/]+)/?$ $1/?$2=$3 [NC,N,DPI,QSA]
RewriteRule ^([a-z0-9_]+)/([a-z0-9_]+)/?$ /index.php?module=$1&function=$2 [NC,QSA,L]
  • 他们将重写此表单中的URL(内部)

    http://www.example.com/main/job/p1=value/p2=something+else/PP=是

    以这种形式

    http://www.example.com/index.php?module=main&function=job&p1=value&p2=something+else&PP=是


  • 这些规则需要放在.htaccess顶部的某个地方——第一个规则使用
    [N]
    标志,它告诉Apache重新开始重写(以便重写所有
    =
    片段)。如果在此之前有很多规则,Apache将不得不在每次迭代后“探测”每个规则,这可能会给web服务器带来不必要的负载


  • 一般来说,不要认为你能做到这一点(你可以用有限的几对来做到)。您可以将整个
    =/=/=
    部分按原样传递给脚本,并让它处理解析。