mod_rewrite 带或不带斜杠的 URL 重写
写出 .htacess 以便 www.domain.com/about_us 和 www.domain.com/about_us/ 都转到 www.domain.com/about_us.php 的正确方法是什么
目前,我所拥有的是以下内容只是想知道是否有办法将其放在一行中
选项+FollowSymLinks
RewriteEngine 开启
RewriteRule ^(about)$ /about_us.php
RewriteRule ^(about/)$ /about_us.php
What is the correct way to write out the .htacess so that both www.domain.com/about_us and www.domain.com/about_us/ goes to www.domain.com/about_us.php
Currently, what I have is the below and just wonder if there's a way to put it in one line
Options +FollowSymLinks
RewriteEngine on
RewriteRule ^(about)$ /about_us.php
RewriteRule ^(about/)$ /about_us.php
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这是一个正则表达式,所以添加 ? / 之后将使 / 可选(出现 0 或 1 次)。另外,括号是不必要的:
It's a regular expression, so adding ? after the / will make the / optional (0 or 1 occurrences). Also, the parenthesis are unnecessary: