0

So I've been playing around with htaccess for Windows Apache, and I wanted to do some minimal parsing of CSS files when it's requested (somewhat like LESS/SASS but with only variables since I don't want to use lots of server resources for every CSS load.)

I tried changing this line in my file:

RewriteCond %{REQUEST_FILENAME} !-d

To:

RewriteCond %{REQUEST_FILENAME} !.(ico,js,jpg,gif,png)$

But that's making all my other files get redirected through my PHP framework, making the output of the document end up being a HTML document, and throws a bunch of exceptions in the Chrome Dev Tools, am I writing this wrong?

The way this is meant to work is Request CSS file from index load > PHP picks it up in framework router > file_get_contents File and parse > Output file after parse & exit

Thanks. :)

1 Answer 1

1

If you just want the redirect to happen for CSS files, you can have RewriteRule apply only when there is a .css extension:

RewriteRule ^(.*\.)css$ $1php
Sign up to request clarification or add additional context in comments.

2 Comments

For the redirect, what file is it being redirected to?
It should redirect to the same path with the extension changed from .css to .php.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.