Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/.htaccess/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
.htaccess在删除php扩展和内部重定向时抛出文件夹外部_.htaccess_Redirect_Mod Rewrite - Fatal编程技术网

.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
中(显然,它们都存在)。它在我这方面的工作与预期一样,只是测试了一下以确保