NLessController not working with path-format URLs enabled

Hi all! My first post here. :)

I’ve got a tiny Yii project going, and trying to use the NLessController extension, which allows you to use LessCSS or SASS files for stylesheets.

I got the extension working but only when in the default URL mode. However, when I activate path-format URLs by uncommenting:


'urlManager'=>array(

    'urlFormat'=>'path',

    'rules'=>array(

        '<controller:\w+>/<id:\d+>'=>'<controller>/view',

        '<controller:\w+>/<action:\w+>/<id:\d+>'=>'<controller>/<action>',

        '<controller:\w+>/<action:\w+>'=>'<controller>/<action>',

    ),

),

in config/main.php, the plugin stops working.

I believe it’s to do with the .htaccess rewrite rules. Which looks as follows:


# Place this file in the root of the app

RewriteEngine on


RewriteCond %{REQUEST_FILENAME} ^.*\.(less|sass|scss)$

	RewriteRule (.*) index.php?r=nless/index&f=$1&%{QUERY_STRING} [L]


# if a directory or a file exists, use it directly

RewriteCond %{REQUEST_FILENAME} !-f

RewriteCond %{REQUEST_FILENAME} !-d

# otherwise forward it to index.php

RewriteRule . index.php


#or simply:

# RewriteRule ^.*$ /index.php [L]



Can anyone offer some advice as to how the rules should be modified to accomodate path-format URLs?

Hi, it’s because you’ve got an [L] set after the extension specific re-write rule, this flag means last, in other words it’s passing something into the index.php that Yii has been configured not to deal with. We still use [L] in the replacement but we need to form the URL in a way Yii setup for path URLs doesn’t choke on.

Try changing:

To:

If you decide to hide the index.php file, you will need to change it to (I think)

The QUERY_STRING part is superfluous, his code throws it away any way and you are only requesting a file.

Hope this pointed you in right direction, I wasn’t able to test this, since I dont use that extension but I did take a quick look at its code.