如何让htaccess在没有文件扩展名的情况下加载页面

时间:2016-03-11 20:30:19

标签: apache .htaccess ubuntu

我已经四处寻找并尝试了一些不同的事情,没有运气。

我在使用网址http://SERVERNAME.com/get.php

时尝试加载此页面http://SERVERNAME.com/get

以下是我现在在htaccess中所拥有的内容:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule !.*\.php$ %{REQUEST_FILENAME}.php [QSA,L]

我已经过测试,确保通过故意破坏并获得500错误来读取我的htaccess文件。

1 个答案:

答案 0 :(得分:1)

Options +FollowSymLinks -MultiViews
RewriteEngine On
RewriteBase /

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.*)$ $1.php [L]

RewriteCond %{THE_REQUEST} ^(?:GET|POST)\ /.*\.php\ HTTP.*$ [NC]
RewriteRule ^(.*)\.php$ $1 [R=301,L]