Topic: nginx rewrite Help

# BEGIN PunBB

<IfModule mod_rewrite.c>
# MultiViews interfers with proper rewriting
Options -MultiViews

RewriteEngine On

# Uncomment and properly set the RewriteBase if the rewrite rules are not working properly
#RewriteBase /

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . rewrite.php [L]
</IfModule>

# END PunBB


I would like to ask how to convert nginx?


if (-f $request_filename/index.html){
            rewrite (.*) $1/index.html break;
        }
        if (-f $request_filename/index.php){
            rewrite (.*) $1/index.php;
        }
        if (!-f $request_filename){
            rewrite (.*) /index.php;
        }
???

Re: nginx rewrite Help

Try just

        location /punbb/ {
            if (!-f $request_filename) {
                rewrite . /punbb/rewrite.php last;
            }
        }

Please, report if it works :-)

Maybe this example will be helpful: http://www.dokuwiki.org/rewrite

Carpe diem

Re: nginx rewrite Help

If your forum URL looks like www.example.com/forum/, for Folder Based or Folder Based (fancy) URL schemes you can use this rewrite rule:

rewrite /forum/.*[^(.php|.css|.png|.jpg|.gif)]$ /forum/rewrite.php last;

If you use File Based or File Based (fancy) URL schemes, you can use this rewrite rule:

rewrite /forum/.+\.html$ /forum/rewrite.php last;

4 (edited by golan 2010-12-14 21:41)

Re: nginx rewrite Help

We installed WYSWYG Editor Extension, but it didn't work because nginx disabled .htm

Page Not found (Error 404): The requested page extensions/punbb_wysiwyg/tiny_mce/themes/advanced/source_editor.htm could not be found.

Upon our investigation, the problem was in this line:

rewrite /.*[^(.php|.css|.png|.jpg|.gif)]$ /rewrite.php last;

A better solution:

location /  {
..............
   try_files $uri $uri/ @rewrite;
                                    }

location @rewrite {
    include /etc/nginx/fastcgi_params;
    fastcgi_param SCRIPT_NAME /rewrite.php;
    fastcgi_param SCRIPT_FILENAME $document_root/rewrite.php;
    fastcgi_pass   127.0.0.1:9000;
}

It worked on nginx/0.8.35, not sure about older versions.

Re: nginx rewrite Help

Thank you very much!  big_smile
My forums : http://bbs.lcgo.net/
Nginx+Punbb!