Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/apache/9.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 URL重写-参数为空_Regex_Apache_.htaccess_Url Rewriting - Fatal编程技术网

Regex URL重写-参数为空

Regex URL重写-参数为空,regex,apache,.htaccess,url-rewriting,Regex,Apache,.htaccess,Url Rewriting,我正在努力让htaccess文件中的简单URL重写正常工作。看起来是这样的: RewriteRule ^getbars/([A-Za-z\d,]+)?$ getbars.php?guid=$1 [NC,L] 其思想是将/getbar/519f1dec603f9等URL重定向到/getbar.php?guid=519f1dec603f9 但是,由于某些原因,当我尝试在getbar.php中获取guid参数时,它是空的 但是,如果我将其更改为 RewriteRule ^ba

我正在努力让htaccess文件中的简单URL重写正常工作。看起来是这样的:

RewriteRule    ^getbars/([A-Za-z\d,]+)?$    getbars.php?guid=$1    [NC,L]
其思想是将/getbar/519f1dec603f9等URL重定向到/getbar.php?guid=519f1dec603f9

但是,由于某些原因,当我尝试在getbar.php中获取guid参数时,它是空的

但是,如果我将其更改为

RewriteRule    ^bars/([A-Za-z\d,]+)?$    getbars.php?guid=$1    [NC,L]
在我的浏览器中加载/bar/519f1dec603f9,它似乎可以正常工作


我做错了什么?

因为在您的服务器上启用了内容协商功能(结合到此处的路径信息功能)?如果是这种情况,内容协商会在读取重写规则之前自动“重写”getbars/*到getbars.php


=>您可以尝试在.htaccess中添加
选项-多视图吗?

您还有其他重写规则吗?如果你在你列出的第一条规则上面有另一条规则,它将与该规则匹配,并且永远不会达到你想要的规则。不。即使移除所有其他元素,我也会得到相同的结果rules@andlin它可以被浏览器缓存。您是否尝试过清除缓存,或者尝试过其他缓存?事实上,当测试类似的东西时,我建议您在chrome中使用匿名模式。如果要清除缓存,只需关闭选项卡并打开一个新选项卡。