Php 改写问题
我在使用以下规则进行modrewrite时遇到问题。 我得到一个404错误,因为规则似乎不起作用。 有人能提供一个解决方案,让它工作吗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不受重写规则的影响;
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中的第一个/下一个/处停止,这导致它与任何内容都不匹配