I’m trying to pass LESS files over to a PHP compiler via mod_rewrite – when a LESS file is requested, the file should be redirected to the PHP script, passing it’s path/name so a CSS file can be spat out.
HTML:
<link rel="stylesheet/less" type="text/css" href="styles/main.less" />
<link rel="stylesheet" type="text/css" href="styles/main.less.css" />
.htaccess:
RewriteEngine On
RewriteBase /v2/
RewriteRule ^([^.]*\.less)$ compilers/lessphp.php?file=$1 [R,L,NC]
Starting out, there is only a .less file.
Refreshing ‘http://mydomain.com/v2/’ will result in unstyled content. No .css file is created in /styles/.
If I go to ‘http://mydomain.com/v2/styles/main.less’ I’ll be redirected to my PHP compiler ‘http://mydomain.com/v2/compilers/lessphp.php?file=styles/main.less’, and ‘main.less.css’ is created as it should within /styles/. Returning to ‘http://mydomain.com/v2/’, I now have styled content.
Rewrites are only occurring in the URL bar of the browser, not the page of the site.
What am I doing wrong?
EDIT: Is there also a better way to do what I am trying to do?
EDIT2:
/v2/
–index.php
–.htaccess
–/styles/
—-main.less
—-main.less.css
–/compilers/
—-lessphp.php
OK, Figured out the issue. Dead simple really.
Playing around with altering extensions and what not, trying to figure out why images would change freely, yet CSS was not, when it struck me that it might have something to do with file type or what not. This is when I noticed the following
rel="stylesheet/less"is the culprit here, and is used by less.js for client side rendering. Replacing simply withrel="stylesheet"like a normal CSS document, Everything. Just. Worked.Edit: I’ve written a run through to get Lessphp working properly here