.htaccess 删除.php扩展后面临错误

6mw9ycah  于 2023-11-22  发布在  PHP
关注(0)|答案(2)|浏览(131)

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

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

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位于根目录中。
原始URL是:cloud9cumulus.com/shieldpayments/view/login.php

tmb3ates

tmb3ates1#

试试这个

Options -MultiViews

RewriteEngine on

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

字符串
此规则足以删除您当前URL的.php扩展名,并在尝试之前删除与此相关的其他规则。

8ulbf1ek

8ulbf1ek2#

问题的解决方案终于得到了,在这里,

<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>

字符串

相关问题