Username
Forgot password?
Welcome to our site!
Or Join with FTTF

rewrite rules for nginx

5

3002 views

Tested and working, didn't test everything though.

server {
        server_name www.qna.org;
        root /var/www/local/test/LampCMS/www;

    #browse folders if no index file
    autoindex on; 


                rewrite "^/questions([\/]{0,1})$"      /index.php?a=viewquestions break;
        
                rewrite "^/questions/page([0-9]+)\.html"      /index.php?a=viewquestions&pageID=$1 break;
        
                rewrite "^/questions/([0-9]+)/(.*)"      /index.php?a=viewquestion&qid=$1&urltext=$2 break;
        
                rewrite "^/q([0-9]+)/([^\/]+)/([a-zA-Z_]+)/page([0-9]+)\.html"      /index.php?a=viewquestion&qid=$1&urltext=$2&sort=$3&pageID=$4 break;
        
                rewrite "^/q([0-9]+)/(.*)"      /index.php?a=viewquestion&qid=$1&urltext=$2 break;
        
                rewrite "^/ask([\/]{0,1})$"      /index.php?a=askform break;
        
                rewrite "^/voted([\/]{0,1})$"      /index.php?a=viewquestions&cond=voted break;
        
                rewrite "^/voted/page([0-9]+)\.htm([l]{0,1})$"      /index.php?a=viewquestions&cond=voted&pageID=$1 break;
        
                rewrite "^/active([\/]{0,1})$"      /index.php?a=viewquestions&cond=active break;
        
                rewrite "^/active/page([0-9]+)\.htm([l]{0,1})$"      /index.php?a=viewquestions&cond=active&pageID=$1 break;
        
                rewrite "^/unanswered([\/]{0,1})$"      /index.php?a=unanswered break;
        
                rewrite "^/unanswered/noanswers([\/]{0,1})$"      /index.php?a=unanswered&cond=noanswer break;
        
                rewrite "^/unanswered/noanswers/page([0-9]+)\.html$"      /index.php?a=unanswered&cond=noanswer&pageID=$1 break;
        
                rewrite "^/unanswered/tagged/([^\/]*)([\/]{0,1})$"      /index.php?a=unanswered&cond=tagged&tags=$1 break;
        
                rewrite "^/unanswered/tagged/([^\/]*)/page([0-9]+)\.html$"      /index.php?a=unanswered&cond=tagged&tags=$1&pageID=$2 break;
        
                rewrite "^/unanswered/page([0-9]+)\.html$"      /index.php?a=unanswered&pageID=$1 break;
        
                rewrite "^/tags([\/]{0,1})$"      /index.php?a=viewqtags break;
        
                rewrite "^/tags/page([0-9]+)\.htm([l]{0,1})$"      /index.php?a=viewqtags&pageID=$1 break;
        
                rewrite "^/tags/name([\/]{0,1})$"      /index.php?a=viewqtags&cond=name break;
        
                rewrite "^/tags/recent([\/]{0,1})$"      /index.php?a=viewqtags&cond=recent break;
        
                rewrite "^/tags/popular([\/]{0,1})$"      /index.php?a=viewqtags&cond=popular break;
        
                
                rewrite "^/tags/(name|recent|popular)/page([0-9]+)\.html$"      /index.php?a=viewqtags&cond=$1&pageID=$2 break;
        
                
                rewrite "^/tagged/(.*)/$"      /index.php?a=tagged&tags=$1 break;
        
                rewrite "^/tagged/(.*)/page([0-9]+)\.html$"      /index.php?a=tagged&tags=$1&pageID=$2 break;
        
                rewrite "^/vote/([0-9]+)/(up|down)$"      /index.php?a=vote&resid=$1&res=q&type=$2 break;
        
                rewrite "^/ansvote/([0-9]+)/(up|down)$"      /index.php?a=vote&resid=$1&res=a&type=$2 break;
        
                rewrite "^/accept/([0-9]+)$"      /index.php?a=accept&aid=$1 break;
        
                rewrite "^/users/([0-9]+)/(.*)"      /index.php?a=userinfo&uid=$1&username=$2 break;

                rewrite "^/users/([a-zA-Z]+)/page([0-9]+)\.html"      /index.php?a=users&sort=$1&pageID=$2 break;
        
                rewrite "^/users/([a-zA-Z]+)/"      /index.php?a=users&sort=$1 break;
        
        
                
                rewrite /register"      /index.php?a=register break;
        
                rewrite "^/([a-zA-Z\-]+)/page([0-9]+)\.html$"      /index.php?a=$1&pageID=$2 break;
        
                rewrite "^/aa/([0-9]+)/([a-f0-9]+)$"      /index.php?a=activate&eid=$1&hash=$2 break;
        
                rewrite "^/([a-zA-Z\-]+)/$"      /index.php?a=$1 break;
        
                rewrite "^/search/(m|r)/(.*)/page([0-9]+)\.html$"      /index.php?a=search&ord=$1&q=$2&pageID=$3 break;
        
                rewrite "^/tab/(a|q)/([0-9]+)/([a-zA-Z]+)/page([0-9]+)\.html$"      /index.php?a=userinfotab&tab=$1&uid=$2&sort=$3&pageID=$4 break;
        
                rewrite "^/editprofile/([0-9]+)"      /index.php?a=editprofile&uid=$1 last;

            location / {
                    index index.php index.html index.htm;
            }
        location ~ \.php$ {
                #fastcgi_pass  unix:/tmp/php.socket;
                fastcgi_pass  127.0.0.1:9000;
                fastcgi_index index.php;
                include fastcgi_params;
        }
}


 
asked June 4, 2011 at 1:47 AM

 

2 Answers

0
Best answer
 
It seems to be working for my Nginx install. Thank you very much.
flag
answered August 22, 2011 at 3:20 PM
1
 
Thanks, this works great!
flag
answered June 15, 2011 at 10:35 AM
Well then why don't you give me a vote for it?
flag
Jun 16 '11 at 2:37

Your answer

Join with account you already have

FTTF

Preview

Alert