删除.php exetension后面临错误

时间:2016-10-06 10:49:23

标签: php .htaccess core

这是删除.php扩展名后的.htaccess代码。我正面临这个错误

  


错误请求您的浏览器发送了此服务器的请求   无法理解。

 DirectorySlash On
    RewriteCond %{THE_REQUEST} ^GET\s([^.]+)\.php\?id=([^&\s]+)\s [NC]
    RewriteRule ^ %1/%2? [R,L]
    # Redirect external .php requests to extensionless url
    RewriteCond %{THE_REQUEST} ^(.+)\.php([#?][^\ ]*)?\ HTTP/
    RewriteRule ^(.+)\.php$ https://%{HTTP_HOST}/$1/ [L,NC]

编辑:

.htaccess位于根目录中。

原始网址为:cloud9cumulus.com/shieldpayments/view/login.php

2 个答案:

答案 0 :(得分:0)

试试这个,

Options -MultiViews

RewriteEngine on

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^shieldpayments/view/([\w-]+)$ shieldpayments/view/$1.php [L]

此规则足以删除当前网址的.php扩展名,并在尝试之前删除与此相关的其他规则。

答案 1 :(得分:0)

  

问题的解决方案最终得到,而这里是

<IfModule mod_rewrite.c>
Options +FollowSymLinks -MultiViews
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_METHOD} !POST
RewriteCond %{THE_REQUEST} \s/+(.+?)\.php[\s?] [NC]
RewriteRule ^ /%1 [R=302,NE,L]
RewriteCond %{REQUEST_METHOD} !POST
RewriteCond %{THE_REQUEST} /index\.php [NC]
RewriteRule ^(.*)index\.php$ /$1 [L,R=302,NC,NE]
RewriteCond %{REQUEST_FILENAME} -d [OR]
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^ - [L]
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^(.+?)/?$ $1.php [L]

</IfModule>