【发布时间】:2016-03-31 17:46:00
【问题描述】:
我有一个 .htaccess 文件:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^\.]+)$ $1.php [NC,L]
我有一个名为random.php的文件。
我想要做的只是调用something.com/random,但是 Apache 在 URL 的末尾添加了一个斜杠(使用 301 重定向),因此给出了一个错误,指出找不到 something.com/random/.php。
编辑 1:当我使用时
RewriteEngine On
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^(.+?)/?$ $1.php [NC,L]
然后我的外部文件(.js、.css 等)无法加载,服务器以 500 Internal Server Error 响应进行响应。 Apache 说重定向太多了。
【问题讨论】:
标签: php apache .htaccess mod-rewrite