Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I have problem with these rules:

ErrorDocument 500 http://example.com/500.html
RewriteCond %{HTTP_HOST} ^www.example.com$ [NC]
RewriteRule ^(.*)$ http://example.com/$1 [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule (.*) index.php/$1 [L]

Can anyone help me?

share|improve this question
    
What is the problem? What nginx rules have you tried? –  James O'Gorman Jan 30 '13 at 18:11
    
Nothing works. I tried online converters and: if (!-e $request_filename) { rewrite ^.*$ /index.php last; } and try_files $uri $uri/ /index.php?$args; –  kix Jan 30 '13 at 18:24
2  
Please update your question with specific problems, as well as configurations you've tried. At the moment it reads as "it doesn't work, fix it for me". –  James O'Gorman Jan 30 '13 at 18:32

1 Answer 1

Directive

ErrorDocument 500 http://example.com/500.html

transforms to

error_page 500 http://example.com/500.html;



Rewrite from www to non-www server name

RewriteCond %{HTTP_HOST} ^www.example.com$ [NC]
RewriteRule ^(.*)$ http://example.com/$1 [R=301,L]

transforms to this server section:

server {
    server_name  www.example.com;
    rewrite ^ http://example.com$request_uri?;
}



And rewrite block

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule (.*) index.php/$1 [L]

turns into

try_files $uri $uri/ /index.php$request_uri?;



So the resulting nginx config will look like this:

server {
    listen 80;
    server_name  www.example.com;
    rewrite ^ http://example.com$request_uri?;
}

server {
    listen 80;
    server_name  example.com;

    root /var/www/example.com;
    error_page 500 http://example.com/500.html;

    location / {
        index index.php;
        try_files $uri $uri/ /index.php$request_uri?;   
    }

    location ~ \.php$ {
        #
        # PHP processing here
        #
    }       
}
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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