Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/.htaccess/5.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重写规则不起作用_.htaccess - Fatal编程技术网

.htaccess重写规则不起作用

.htaccess重写规则不起作用,.htaccess,.htaccess,我正在使用scssphp进行css预处理,现在我的样式看起来像src=“style.php/style.scss”。我想要的是使用一个htaccess以样式编写,然后任何以.scss结尾的内容都将通过style.php运行。所以我试着把这个放在我的主目录里 RewriteEngine On RewriteRule ^(.*)\.scss$ style.php/$1.scss 我甚至试过 #RewriteEngine On #RewriteRule ^(.*)\.scss$ style.php/

我正在使用scssphp进行css预处理,现在我的样式看起来像
src=“style.php/style.scss”
。我想要的是使用一个htaccess以样式编写,然后任何以
.scss
结尾的内容都将通过
style.php
运行。所以我试着把这个放在我的主目录里

RewriteEngine On
RewriteRule ^(.*)\.scss$ style.php/$1.scss
我甚至试过

#RewriteEngine On
#RewriteRule ^(.*)\.scss$ style.php/style.scss

这两种方法都不起作用,因为my style.scss加载时出现了500个内部服务器错误,但我不确定错误在哪里。

获取请求文件名的更好的正则表达式是
[a-z_a-z]+.scss


使用此语法尝试htaccess

如果规则正在循环,请尝试添加一个附加检查,以便在URI中包含style.php时不重写:

RewriteEngine On
RewriteCond %{REQUEST_URI} !style\.php
RewriteRule ^(.*)\.scss$ style.php/$1.scss
重写引擎将继续循环您的规则,直到URI停止更改。您的规则发生的情况是,像
/path/style.scss
这样的请求正在被处理并重写为
/style.php/path/style.scss
,重写引擎循环。第二次,再次应用该规则,并将其重写为:
/style.php/style.php/path/style.scss
,等等