2011-08-31 66 views
0

我使用下面的规则modrewrite有问题。 我收到了404错误,因为规则似乎不起作用。 有人可以提供解决方案如何让它工作?modrewrite问题

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

应该处理以下,但给了我404像URL:

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

在此先感谢。

回答

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

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

我不知道你想要什么,以便准确,但对于您的示例网址,你可以使用类似:

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

这将使az(大写和小写)和正斜杠。

1

试试这个规则:

RewriteRule ^/catalogue/(.+?)/results.html$ /search.php?data=$1 [l] 

,因为你的拍摄模式您的规则不工作:

[^/\.]+ 

基本上是指:

Match anything that is not a/or a . for as many times as possible. 

但它会在停止首先下一个/在网址,这导致它不匹配任何东西