Nginx and rewrite rules....

I am playing with nginx and have it running pretty smoothing with Dolphin 7.04.  There is one rewrite rule that is causing problems with the entire site.

 

# profile rewrite
if (!-e $request_filename ) {
rewrite  ^/([^/]+)$  /profile.php?ID=$1  last;
break;

}

 

Without this one rule, everything is flawless, I just have to turn off friendly profile permalinks. in Settings -> Permalinks

as it is posted in

http://www.boonex.com/trac/dolphin/wiki/TutorialHowToInstallDolphinOnNginx

it must be changed as it has /path_to_dolphin/ and hence it being removed - rewrite  ^/([^/]+)$  /profile.php?ID=$1  last;

With those code and friendly profile permalinks enabled, it actually trashes the entire site, as if it loses all css, any style, tables etc...

 

Has anyone found a fix for this?  Is my code just wrong?

 

Nginx is great and will use it regardless, even if I never am able to turn permalinks on for friendly profile, but would like to get it fixed.

Quote · 22 Dec 2010

# profile rewrite
        if (!-e $request_filename ) {
            rewrite  ^/path_to_dolphin/([^/]+)$  /path_to_dolphin/profile.php?ID=$1  last;
            break;
        }

It seems they have path to dolphin twice..  could this be why its not working for you ?

https://dolphin-techs.com - Skype: Dolphin Techs
Quote · 22 Dec 2010

Where do you see the path twice?  a rewrite is telling one item to go to another which is what its doing, this code as posted on the link above was posted by boonex, but, I cant figure out why its wrong....

Quote · 22 Dec 2010

we are using this rule on www.boonex.us on nginx/0.7.65 withiut any problems:

# profile rewrite
if (!-e $request_filename ) {
rewrite  ^/([^/]+)$  /profile.php?ID=$1  last;
break;
}

This rule is in location / { ... } clause.

Rules → http://www.boonex.com/terms
Quote · 23 Dec 2010

I am running 7.04 I dont have access to 7.65 Tongue out

I even cut and pasted what you had in your post I get exact same results.  trashes the sites layout even with the permlink disabled.

Will play with it, and post any findings.  If anyone else has any feedback or has this working, would love to know.

 

I am running Centos 5.5

Ngios 0.8.53

PHP 5.3.3 via php-fpm

Quote · 23 Dec 2010

AlexT

Would it be possible to get exact code for the profile rewrite from your nginx.conf ?

I have tried it a few ways and nothing but problems.... possibly I am not laying it out correctly.

 

Thanks

Quote · 23 Dec 2010

Looks like I got it all set.... it did work under the location / { ... though this might confuse some as it did me a little at first... put this line under your

location / {

root ....

index....

if (!-e $request_filename) {
rewrite  ^/([^/]+)$  /profile.php?ID=$1  last;
break;

}

}

Quote · 23 Dec 2010

It is great that you resolved the problem, we also have all rewrite rules in  location / { ... } clause.

I mean nginx version - 0.7.65, but you have newer one, from another branch - 0.8.x

Dolphin is the same - v.7.0.4

Also I've provided the exact code - we are using on boonex.us site.

Rules → http://www.boonex.com/terms
Quote · 24 Dec 2010
After re-doing my entire nginx config today and tweaking it a little more, I decided to seperate the host file from the nginx.conf and this does make things like all the rewrite and whatnot for dolphin MUCH easier. nginx is a little more touchy than even apache config files, but by seperating it I was able to really work it all out. appreciate the help ALexT, and I hope this thread helps many others as nginx is without a doubt a much better handler than apache would be... for any site expecting or having heavy traffic.
Quote · 24 Dec 2010

Guys, I'm having trouble figuring out how to make the rewrite rules work.

I've added in nginx.conf file the line "include /usr/share/nginx/html/dolphin/dolphin_rewrite.conf;" right after the line "include /etc/nginx/conf.d/*.conf;"  - inside the "http" section.
Inside the file dolphin_rewrite.conf I added the rewrite rules, wrapped in a section "server". I don't know if that's the right way to do it (damn boonex! Why not explain in detail what has to be done?!), but the nginx reloaded OK after that. I don't know where to look for that "location" clause mentioned in this post several times and if I replace "server" with "location", nginx complains and doesn't restart.
BTW, the path that I gave in the .conf file was /dolphin/, rather than /usr/share/nginx/html/dolphin. Again, hope this is correct. Actually I tried both, none worked for me...
Any help would be appreciated!
(running Dolphin 7.1.1, nginx 1.2.8)
Quote · 14 Apr 2013

I was under the impression that newer versions above .96 i think had mod_rewrite working by default.  no need to add rewrite rules anymore.

At least that is the case when using nginx admin anyway... 

https://dolphin-techs.com - Skype: Dolphin Techs
Quote · 14 Apr 2013

 

Inside the file dolphin_rewrite.conf I added the rewrite rules, wrapped in a section "server". I don't know if that's the right way to do it

This is not correct way.

Rewrite rules are for location section, for example:

location /path_to_dolphin {
    index  index.html index.htm index.php;
    # rewrite rules goes here
}
 
I've update wiki with this example as well.
Rules → http://www.boonex.com/terms
Quote · 15 Apr 2013

Will try to help with this when I can.  Your set up is a little different and I don't think you should do an include for all config files; for one, I saw an example config file and you certainly don't want to include that for Nginx config.  Only include the specific includes you want; don't just grab all of them.

Geeks, making the world a better place
Quote · 15 Apr 2013
 
 
Below is the legacy version of the Boonex site, maintained for Dolphin.Pro 7.x support.
The new Dolphin solution is powered by UNA Community Management System.