删除 .php 扩展后遇到错误
Facing error after removing .php exetension
这是删除 .php 扩展名后我的 .htaccess 代码。我遇到了这个错误
Bad Request Your browser sent a request that this server
could not understand.
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}// [L,NC]
编辑:
.htaccess 位于根目录中。
原文URL是这样的:cloud9cumulus.com/shieldpayments/view/login.php
试试这个,
Options -MultiViews
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^shieldpayments/view/([\w-]+)$ shieldpayments/view/.php [L]
此规则足以删除您当前 url 的 .php 扩展名,并在尝试之前删除与此相关的其他规则。
The solution of problem finally get and here it is
<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$ / [L,R=302,NC,NE]
RewriteCond %{REQUEST_FILENAME} -d [OR]
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^ - [L]
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^(.+?)/?$ .php [L]
</IfModule>
这是删除 .php 扩展名后我的 .htaccess 代码。我遇到了这个错误
Bad Request Your browser sent a request that this server could not understand.
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}// [L,NC]
编辑:
.htaccess 位于根目录中。
原文URL是这样的:cloud9cumulus.com/shieldpayments/view/login.php
试试这个,
Options -MultiViews
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^shieldpayments/view/([\w-]+)$ shieldpayments/view/.php [L]
此规则足以删除您当前 url 的 .php 扩展名,并在尝试之前删除与此相关的其他规则。
The solution of problem finally get and here it is
<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$ / [L,R=302,NC,NE]
RewriteCond %{REQUEST_FILENAME} -d [OR]
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^ - [L]
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^(.+?)/?$ .php [L]
</IfModule>