I installed Anchor CMS on my server running Lighttpd, and I am trying to setup pretty url's. I have anchor installed in a sub-directory "/blog".

The htaccess file that works with anchor cms in apache is:

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /blog

    # Checks to see if the user is attempting to access a valid file,
    # such as an image or css document, if this isn't true it sends the
    # request to index.php
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^(.*)$ index.php/$1 [L]

<IfModule !mod_rewrite.c>
    ErrorDocument 404 /index.php

This is the rewrite rule I have in lighttpd:

url.rewrite-if-not-file += ( "^/blog/(.*)$" => "/blog/index.php/$1")        

The urls are now pretty, but none of the static content is loading, ie css, javascript and images. I thought using url.rewrite-if-not-file would cover this, but it doesn't seem to be working for my installation. http://redmine.lighttpd.net/projects/1/wiki/Docs_ModRewrite#urlrewrite-repeat-if-not-file

The following urls and their files need to be kept intact:

  • /blog/themes/default/{ js | css | img }
  • /blog/anchor/views/assets/{ js | css | img }

The theme directory can change depending on the theme currently being used. So instead of "default" it could be "example". I am not very good with regex, so I could really use some help. I was thinking something along the lines of this might work:

url.rewrite-once += ("^/blog/themes/(.*.)/(css|js|img)/(.*)" => "$0")

Any assistance with this would be greatly appreciated. Lighttpd uses regrex similar to perl


I got this working with the following rewrite rules:

url.rewrite-if-not-file += ( "^/(.*)\.(css|js|jpg|png|gif)$" => "$0",
                             "^/blog/(.*)$" => "/blog/index.php/$1" )

I hope this helps someone else running anchor cms on lighttpd

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.