URL 重写查询
我想了解这些重写规则的含义
RewriteRule ^([^/]+)/([^/]+).html /title.php?file=$1&sub1=$2 [NC]
,
RewriteRule ^admin/reg/([^/]+) /admin.php?file=$1 [NC]
请举例说明如何将其重定向到 title.php
I want to understand what is meaning of these Rewrite rules
RewriteRule ^([^/]+)/([^/]+).html /title.php?file=$1&sub1=$2 [NC]
And
RewriteRule ^admin/reg/([^/]+) /admin.php?file=$1 [NC]
Kindly give me example, how it would be redirected to title.php
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您访问
http://yourdomain/yomomma/house.html
,它将重定向到/title.php?file=yomamma&sub1=house
第二个
http://yourdomain/admin/reg/candyfloss
将重定向到/admin.php?file=candyfloss
NC 使其不区分大小写。
查看此页面,了解有关正则表达式(RewriteRule 第一部分中使用的内容)的更多信息 正则表达式快速入门。正则表达式基本上允许您搜索字符串。您发布的示例选取了除反斜杠之外的任何字符(无论如何,反斜杠都用于破坏您的参数)。
If you went to
http://yourdomain/yomomma/house.html
it would redirect to/title.php?file=yomamma&sub1=house
The second one
http://yourdomain/admin/reg/candyfloss
would redirect to/admin.php?file=candyfloss
NC makes it case insensitive.
Check out this page for more information on Regex (which is what's used in the first part of the RewriteRule) Regex Quickstart. Regex basically allows you to search strings. The example you posted picks up any characters except backslashes (which are used to break your parameters anyways).