qw3n
qw3n

Reputation: 6334

.htaccess rewrite rules not working

I am using scssphp for my css preprocessing and right now my styles look like src="style.php/style.scss". What I was wanting is to use a htaccess to just write in the style and then anything ending in .scss would get run through style.php. So I tried putting this in my home directory.

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

I even tried

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

Neither work, something is happening, because my style.scss is loading with a 500 internal server error, but I'm not sure where the error is.

Upvotes: 0

Views: 59

Answers (2)

Jon Lin
Jon Lin

Reputation: 143856

Your rules are looping, try adding an additional check to not rewrite when the URI has style.php in it:

RewriteEngine On
RewriteCond %{REQUEST_URI} !style\.php
RewriteRule ^(.*)\.scss$ style.php/$1.scss

The rewrite engine will continue to loop through your rules until the URI stops chanmging. What's happening with your rule is that a request like /path/style.scss is getting procfessed and rewritten to /style.php/path/style.scss, and the the rewrite engine loops. The second time around, the rule gets applied again and it rewrites to: /style.php/style.php/path/style.scss, etc.

Upvotes: 1

hosseind600
hosseind600

Reputation: 26

a better regex to get requested file name would be [a-z_A-Z]+.scss

try your htaccess using this syntax

Upvotes: 0

Related Questions