RewriteRule指令重定向到不存在的页面
我在 .htaccess 文件中设置指令时遇到问题。试图实现这一点,如果访问者尝试打开
http://localhost/occasions/anniversary/
...它必须调用根目录中的 browser.php 文件,并发送“周年纪念”作为参数之一。
我定义了如下指令:
RewriteRule ^/occasions/(.*)/$ http://localhost/browse.php?page=$1
... 但它返回页面未找到错误。
你能告诉我为什么吗,并帮我解决这个问题。
预先非常感谢您!
I have trouble setting directives in .htaccess file. Trying to achieve that if visitor tries to open
http://localhost/occasions/anniversary/
... it have to call browse.php file in root directory, and to send 'anniversary' as one of the parameters.
I defined directive like:
RewriteRule ^/occasions/(.*)/$ http://localhost/browse.php?page=$1
... but it returns Page not found error.
Can you tell me why, and help me to solve this.
Thank you very much in advance!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
只需删除 RewriteRule 中的第一个斜杠,如下所示:
在
.htaccess
文件中使用 RewriteRule 时,它不会匹配,因为第一个斜杠不会传递用于评估。Just remove your first slash in your RewriteRule, like this:
It won't match when using RewriteRule within
.htaccess
files, as this first slash isn't passed for evaluation.尝试使用 Firefox + TamperData Addon 并检查响应以查看页面重定向而不是
browse.html
。https://addons.mozilla.org/en-US/firefox/插件/篡改数据/
Try it with Firefox + TamperData Addon and check the response to see where is the page redirecting instead of
browse.html
.https://addons.mozilla.org/en-US/firefox/addon/tamper-data/