0

I have a nginx + php on windows server configured. I work on an MVC framework with url rewriting, the problem is that my server does not resolve the addresses. Quite simply, this is my code:

server {

    listen 127.0.0.1:80;
    server_name localhost/kuimbi;
    root www/kuimbi;

    index index.php;


    location / {
        if (!-e $request_filename){
            rewrite ^(.+)$ /index.php?url=$1 break;
        }
    }


    location ~* ^.+\.(jpg|jpeg|gif|png|ico|swf|flv|woff)$ {
        access_log off;
        expires 9d;
    }

    location ~* ^.+\.(css|js)$ {
        access_log off;
        expires 1d;
    }

    location ~ \.php$ {
        try_files      $uri =404;
        fastcgi_pass   127.0.0.1:9100;
        fastcgi_index  index.php;
        fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
        include        fastcgi_params;
    }

    error_log  logs/error.log;
    error_log  logs/error.log  notice;
    error_log  logs/error.log  info;
    access_log  logs/access.log  main;
}

And in apache I have the equivalent code:

Options -MultiViews

RewriteEngine On

Options -Indexes

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-l

RewriteRule ^(.+)$ index.php?url=$1 [QSA,L]
Dave M
  • 4,514
  • 22
  • 31
  • 30
Victor
  • 1
  • 1
  • Please add information on the exact file locations and web root directory location. Without that information it is not possible to give an exact answer. – Tero Kilkanen Nov 03 '14 at 00:00

1 Answers1

0

Assuming your requests look like http://localhost/kuimbi/*, you misconfigured the server_name.

It must not contain URI, just domain names.

So your configuration should look like this instead :

server {

    listen 127.0.0.1:80;
    server_name localhost;
    root www/kuimbi;

    location ~ ^/kuimbi/(.*)$ {
        try_files /www/kuimbi/$1 /index.php?url=/$1;
    }

    ...

}
Xavier Lucas
  • 13,095
  • 2
  • 44
  • 50
  • First of all thanks for answering the problem persists, get a page not found error. I tried what you mention as is me ... and nothing. Any suggestions? Thank you. – Victor Nov 02 '14 at 21:24