mod 重写 - 允许句号
我需要一个允许句号的重写规则。我怎么能允许这样呢?我想要的是为了 shop/domain/www.test.com 成为 shop/domain/controller.php?param1=www.test.com
我原来的规则如下:
RewriteRule ^shop/domain/([^/.]+)/? $ shop/stock/controller.php?param1=$1 [NC]
这有效,但前提是我删除句号。
我还尝试了以下操作:
RewriteRule ^shop/domain/([^/]+)/?$ shop/domain/controller.php?param1=$1 [NC]
这允许句号,但随后有controller.php参数应为 www.test.com。
I need a rewrite rule that allows full stops. How can I allow for this? What I want is for
shop/domain/www.test.com to become shop/domain/controller.php?param1=www.test.com
The original rule I have is below:
RewriteRule ^shop/domain/([^/.]+)/?$ shop/stock/controller.php?param1=$1 [NC]
This works but only if I remove the full stop.
I have also tried the following:
RewriteRule ^shop/domain/([^/]+)/?$ shop/domain/controller.php?param1=$1 [NC]
This allows the full stop but then has controller.php is the parameter when it should be www.test.com.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果所有域都以“www.”开头,您可以执行此操作。
您的规则的问题是,它也与
controller.php
匹配,就好像它是一个域一样。您可以添加以下两个重写条件来防止这种情况:!-d
表示不是现有目录,!-f
表示不是现有文件(例如controller.txt)。 php
)。If all domains begin with "www.", you could do this
The problem with your rule is, that it also matches
controller.php
as if it were a domain. You can add the following two rewrite conditions to prevent this:!-d
means not an existing directory,!-f
means not an exisiting file (e.g.controller.php
).