Nginx Rewrite Apache?

Adrian Janeczek nginx-forum at
Sat Apr 16 01:36:09 MSD 2011

I've next trouble

This for nginx
RewriteEngine On
RewriteBase /

RewriteCond %{HTTP_HOST} ^www\.zzz\.pl$ [NC]
RewriteRule ^(.*)$$1 [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule .* index.php?$0 [PT,L]
This is uri but i use this conf 

and this not work

server {
    listen 80;
 #   access_log    /var/log/nginx/zzz.log;
  #  error_log /var/log/nginx/zzz.log;
    root   /home/zzz/public_html;
    index  index.php index.html index.htm;
    location / {
        if (!-e $request_filename) {
            rewrite ^/(.*)$ /index.php?$1 last;
    location ~ .php($|/) {
        set $script     $uri;
        set $path_info  "";
        if ($uri ~ "^(.+.php)(/.+)") {
            set $script     $1;
            set $path_info  $2;
        fastcgi_index  index.php;
        fastcgi_param  SCRIPT_FILENAME    $document_root$script;
        fastcgi_param  SCRIPT_NAME        $script;
        fastcgi_param  PATH_INFO          $path_info;
        fastcgi_param  QUERY_STRING       $query_string;
        fastcgi_param  REQUEST_METHOD     $request_method;
        fastcgi_param  CONTENT_TYPE       $content_type;
        fastcgi_param  CONTENT_LENGTH     $content_length;
        fastcgi_param  REQUEST_URI        $request_uri;
        fastcgi_param  DOCUMENT_URI       $document_uri;
        fastcgi_param  DOCUMENT_ROOT      $document_root;
        fastcgi_param  SERVER_PROTOCOL    $server_protocol;
        fastcgi_param  GATEWAY_INTERFACE  CGI/1.1;
        fastcgi_param  SERVER_SOFTWARE    nginx;
        fastcgi_param  REMOTE_ADDR        $remote_addr;
        fastcgi_param  REMOTE_PORT        $remote_port;
        fastcgi_param  SERVER_ADDR        $server_addr;
        fastcgi_param  SERVER_PORT        $server_port;
        fastcgi_param  SERVER_NAME        $server_name;
        fastcgi_param  REDIRECT_STATUS    200;

Posted at Nginx Forum:,190307,191610#msg-191610

More information about the nginx mailing list