Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/joomla/2.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 重定向url(如果它具有特定扩展名)_.htaccess - Fatal编程技术网

.htaccess 重定向url(如果它具有特定扩展名)

.htaccess 重定向url(如果它具有特定扩展名),.htaccess,.htaccess,如何将扩展名为.css或.js但不是.php的URL重定向到特定文件夹 我的意思是,所有有扩展名但扩展名不是php的URL都应该重定向到特定的文件夹 我尝试这样做,但不起作用: RewriteCond %{REQUEST_URI} \.(.{2,4}!php)$ RewriteCond %{REQUEST_FILENAME} -f RewriteRule ^(.*)\.(.{2,4}!php)$ folder/$1.$2 [L] 你的正则表达式不对,你只需要!\。php$: RewriteCo

如何将扩展名为.css或.js但不是.php的URL重定向到特定文件夹

我的意思是,所有有扩展名但扩展名不是php的URL都应该重定向到特定的文件夹

我尝试这样做,但不起作用:

RewriteCond %{REQUEST_URI} \.(.{2,4}!php)$
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^(.*)\.(.{2,4}!php)$ folder/$1.$2 [L]

你的正则表达式不对,你只需要
!\。php$

RewriteCond %{REQUEST_URI} \.\w{1,4}$
RewriteCond %{REQUEST_URI} !\.php$ [NC]
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^(.*)$ folder/$1 [L]

我找到了解决办法:

RewriteCond %{REQUEST_URI} \.(.{2,4})$
RewriteCond %{REQUEST_URI} !\.(php)$
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^(.*)$ $1 [L]
首先我检查扩展名是否在desire length中,然后我检查它是否不是以.php结尾