Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/270.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
Php 改写问题_Php_Mod Rewrite - Fatal编程技术网

Php 改写问题

Php 改写问题,php,mod-rewrite,Php,Mod Rewrite,我在使用以下规则进行modrewrite时遇到问题。 我得到一个404错误,因为规则似乎不起作用。 有人能提供一个解决方案,让它工作吗 RewriteRule ^/catalogue/([^/\.]+)/results.html$ /search.php?data=$1 [L] 它应该像下面那样处理URL,但给我一个404: http://www.mydomain.com/catalogue/europe/germany/results.html 提前感谢。您的示例url不受重写规则的影响;

我在使用以下规则进行modrewrite时遇到问题。 我得到一个404错误,因为规则似乎不起作用。 有人能提供一个解决方案,让它工作吗

RewriteRule ^/catalogue/([^/\.]+)/results.html$ /search.php?data=$1 [L]
它应该像下面那样处理URL,但给我一个404:

http://www.mydomain.com/catalogue/europe/germany/results.html

提前感谢。

您的示例url不受重写规则的影响;使用
[^/\.]+
允许除正斜杠和点之外的所有字符,因此
欧洲/德国
不匹配,因为它有正斜杠

RewriteRule ^catalogue/(.+?)/results.html$ /search.php?data=$1 [L]
我不知道您到底想允许什么,但对于您的示例url,您可以使用如下内容:

RewriteRule ^/catalogue/([a-zA-Z/]+)/results.html$ /search.php?data=$1 [L]

这将允许
a
z
(大写和小写)和正斜杠。

您的示例url不受重写规则的影响;使用
[^/\.]+
允许除正斜杠和点之外的所有字符,因此
欧洲/德国
不匹配,因为它有正斜杠

我不知道您到底想允许什么,但对于您的示例url,您可以使用如下内容:

RewriteRule ^/catalogue/([a-zA-Z/]+)/results.html$ /search.php?data=$1 [L]
这将允许
a
z
(大写和小写)和正斜杠。

尝试以下规则:

RewriteRule ^/catalogue/(.+?)/results.html$ /search.php?data=$1 [l]
由于您的捕获模式,您的规则不起作用:

[^/\.]+
基本上是指:

Match anything that is not a / or a . for as many times as possible.
但它将在url中的第一个/下一个/处停止,这将导致它与任何内容都不匹配

请尝试以下规则:

RewriteRule ^/catalogue/(.+?)/results.html$ /search.php?data=$1 [l]
由于您的捕获模式,您的规则不起作用:

[^/\.]+
基本上是指:

Match anything that is not a / or a . for as many times as possible.
但它将在url中的第一个/下一个/处停止,这导致它与任何内容都不匹配