【发布时间】:2018-01-17 05:10:52
【问题描述】:
这是我目前访问不带扩展名的 php 文件的重写规则。
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.*?)/?$ $1.php [L]
但是,我希望能够像这样格式化 URL,
https://example.com/somefile/parameter
所以,像,
https://example.com/check_user/12345
但是,当斜杠 (/) 后面有尾随参数时,我得到 500 Internal Server Error。
我真的很想深入了解这个重写规则并征服它,但我根本没有时间这样做。 (按生产要求。)
非常感谢您的帮助。
【问题讨论】:
-
除了 404 重定向规则外,我没有任何其他规则。示例 URL:example.com/somefile/parameter 将导致错误。而example.com/somefile 没有。在这种情况下,somefile 是一个 php 文件,somefile.php
-
顺便说一句,example.com/somefile.php/parameter 工作正常。
标签: php apache .htaccess mod-rewrite url-rewriting