Search

Hey y'all, I'm really interested in utilizing Nginx for my webserver and my main holdout is understanding how to adjust the the Symphony .htaccess so you can run a Symphony site on Nginx. I'm asking this here to see if anyone else has been successful running Symphony on Nginx.

Unfortuantely, I'm having a hard time moving over to Nginx rewrite rules. I'll post my attempt at the Nginx rewrite rules, but first I'm going to post the mod_rewrite rules of Symphony, so we have the direct comparison. If anyone knows Nginx... your help is much appreciated!!!

Here's the regular mod_rewrite for the index.php in document root folder for Symphony...

Original Symphony 2 .htaccess

### DO NOT APPLY RULES WHEN REQUESTING "favicon.ico"
RewriteCond %{REQUEST_FILENAME} favicon.ico [NC]
RewriteRule .* - [S=14] 

### IMAGE RULES 
RewriteRule ^image\/3\/([0-9]+)\/([0-9]+)\/([1-9])\/([a-fA-f0-9]{3,6})(\/(0|1))?\/(.+)\.(jpg|gif|jpeg|png|bmp)$ /symphony/image.php?param=3:$1:$2:$3:$4:$6:$7.$8 [L]
RewriteRule ^image\/2\/([0-9]+)\/([0-9]+)\/([1-9])(\/(0|1))?\/(.+)\.(jpg|gif|jpeg|png|bmp)$ /symphony/image.php?param=2:$1:$2:$3:0:$5:$6.$7 [L]
RewriteRule ^image\/1\/([0-9]+)\/([0-9]+)(\/(0|1))?\/(.+)\.(jpg|gif|jpeg|png|bmp)$ /symphony/image.php?param=1:$1:$2:0:0:$4:$5.$6 [L]
RewriteRule ^image(\/(0|1))?\/(.+)\.(jpg|gif|jpeg|png|bmp)$ /symphony/image.php?param=0:0:0:0:0:$2:$3.$4 [L]

### CHECK FOR TRAILING SLASH - Will ignore files
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !/$
RewriteCond %{REQUEST_URI} !(.*)/$
RewriteRule ^(.*)$ /$1/ [L,R=301]

### MAIN REWRITE - This will ignore directories
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)\/$ /index.php?page=$1&%{QUERY_STRING} [L]

My Nginx attempt

I don't think this is right, but would love to get some input.

location / {
    if ($request_filename="favicon.ico") {
        rewrite  ^(.*)$  break;
    }

    ### IMAGE RULES
    rewrite ^image\/3\/([0-9]+)\/([0-9]+)\/([1-9])\/([a-fA-f0-9]{3,6})(\/(0|1))?\/(.+)\.(jpg|gif|jpeg|png|bmp)$ /symphony/image.php?param=3:$1:$2:$3:$4:$6:$7.$8 last;
    rewrite ^image\/2\/([0-9]+)\/([0-9]+)\/([1-9])(\/(0|1))?\/(.+)\.(jpg|gif|jpeg|png|bmp)$ /symphony/image.php?param=2:$1:$2:$3:0:$5:$6.$7 last;
    rewrite ^image\/1\/([0-9]+)\/([0-9]+)(\/(0|1))?\/(.+)\.(jpg|gif|jpeg|png|bmp)$ /symphony/image.php?param=1:$1:$2:0:0:$4:$5.$6 last;
    rewrite ^image(\/(0|1))?\/(.+)\.(jpg|gif|jpeg|png|bmp)$ /symphony/image.php?param=0:0:0:0:0:$2:$3.$4 last;

    ### CHECK FOR TRAILING SLASH - Will ignore files
    if (!-f $request_filename) {
        rewrite ^/(.+)$ /$1/ permanent;
    }

    ### MAIN REWRITE - This will ignore directories
    if (!-d $request_filename) {
        rewrite ^/(.+)$ /index.php?url=$1 last;
    }   
}

OK. I didn't have much success even getting PHP to work properly in NGINX. That's totally due to my lack of ability than anything else. For those who aren't faint of heart, it looks like a very solid and super fast webserver environment. If you don't mind changing all your .htaccess files to their rewrite rules, you should be good to go. Just not for me though.

Anyway, I thought I'd post the responses that I received from some of the developers of NGINX on my query above. The responses are located here.

Brian, I'm planning on trying out nginx as well. I came across this: http://blog.taragana.com/index.php/archive/nginx-hacking-tips/

One of the examples he uses for converting .htaccess files to nginx config is this:

"RewriteRule ^[a-z0-9_-]*-f([0-9]+)/?(p([0-9]+).html)?$ /viewforum.php?f=$1&start=$3 [QSA,L,NC]

becomes this in nginx:

rewrite ^/[a-z0-9_-]*-f([0-9]+)/?(p([0-9]+).html)?$ /viewforum.php?f=$1&start=$3 last;"

Is it possible your rules are failing for lack of a simple / ?

it could be. i'm actually got litespeed up and running on my slice again. i was trying to test it on my slice at slicehost since I had to rebuild it. but that could have been my problem was that /.

BZ

Hi!

I actually worked this out: Symphony CMS on nginx

That’s awesome kuba, when the article section is set up here, your article should definitely be linked up.

kuba, now that symphony uses simplexml in version 203 (at least i think it is) could this artcle of yours be of use to us, or am i missing the point?

@Allen great!

@newnomad That post is symfony framework related.

And unfortunately Symphony does not yet use SimpleXML/DomDocument under the hood — the propriatary XMLElement class is still in use.

I didn’t dig into the code yet but what stops you with migration?

Oh Nick I thought I read somewhere here that domdocuemtn, as would be in v3.0 was now in 2.0.3? Didn’t it happen in the end then?

See Rowan Lewis’s post on this subject on his personal site.

Create an account or sign in to comment.

Symphony • Open Source XSLT CMS

Server Requirements

  • PHP 5.3-5.6 or 7.0-7.3
  • PHP's LibXML module, with the XSLT extension enabled (--with-xsl)
  • MySQL 5.5 or above
  • An Apache or Litespeed webserver
  • Apache's mod_rewrite module or equivalent

Compatible Hosts

Sign in

Login details