.htaccess在删除php扩展和内部重定向时抛出文件夹外部
我是根据这个问题工作的 () 但这会将我发送到根文件夹.htaccess在删除php扩展和内部重定向时抛出文件夹外部,.htaccess,redirect,mod-rewrite,.htaccess,Redirect,Mod Rewrite,我是根据这个问题工作的 () 但这会将我发送到根文件夹 RewriteEngine On # browser requests PHP RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /([^\ ]+)\.php RewriteRule ^/?(.*)\.php$ /$1 [L,R=301] # check to see if the request is for a PHP file: RewriteCond %{REQUEST_FILENAME}\.php -
RewriteEngine On
# browser requests PHP
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /([^\ ]+)\.php
RewriteRule ^/?(.*)\.php$ /$1 [L,R=301]
# check to see if the request is for a PHP file:
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^/?(.*)$ /$1.php [L]
例如,我的原始url重定向后,它会将我发送到,这里有一个可以处理子文件夹的通用规则
Options -MultiViews
RewriteEngine On
# browser requests PHP
RewriteCond %{REQUEST_FILENAME} -f
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /(.+/)?([^/\s\?&]+)\.php
RewriteRule ^ /%1%2 [L,R=301]
# check to see if the request is for a PHP file:
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.+)$ /$1.php [L]
谢谢,但我得到404错误,甚至文件存在于系统上。。换句话说,我得到了404错误和abc.php存在于server@SaurabhSharma请确保文件
abc.php
位于文件夹products
中(显然,它们都存在)。它在我这方面的工作与预期一样,只是测试了一下以确保