Вопрос

I setup a nginx server in my localhost So now I want to enable clean url for this server

(Change localhost/drupalsite/?q=abc to localhost/drupalsite/abc)

I have tried some tutorials but thet don't work for me

http://wiki.nginx.org/Drupal
https://drupal.org/node/976392
http://richardbanks.net/blog/2012/11/nginx-url-rewrites-the-correct-method

This is some basic config in nginx.conf file

server {
        listen       8080;
        server_name  localhost;

        #charset koi8-r;

        #access_log  /var/log/nginx/host.access.log  main;

        location / {
            root   /srv/nginx/www/nginx_htdocs/;
            index  index.html index.htm index.php;

        }


        #error_page  404              /404.html;

        # redirect server error pages to the static page /50x.html
        #
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   /srv/nginx/www/nginx_htdocs/;
        }

        # proxy the PHP scripts to Apache listening on 127.0.0.1:80
        #
        #location ~ \.php$ {
        #    proxy_pass   http://127.0.0.1;
        #}

        # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
        #
        location ~ \.php$ {
            root           html;
            fastcgi_pass   127.0.0.1:9000;
            fastcgi_index  index.php;
            #fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
            #fastcgi_param SCRIPT_FILENAME $request_filename;
            #fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
            fastcgi_param  SCRIPT_FILENAME  /srv/nginx/www/nginx_htdocs/$fastcgi_script_name;

            include        fastcgi_params;
        }

        #--------------- TUNG CUSTOM





        #------------- END CUSTOM

        # deny access to .htaccess files, if Apache's document root
        # concurs with nginx's one
        #
        #location ~ /\.ht {
        #    deny  all;
        #}
    }
Это было полезно?

Решение

Here's a gist of a full configuration that works very well with Drupal's clean URL's

Другие советы

You must try to handle not found urls as possible query strings for index.php (if that's how Drupal works, which I'm not sure).

For example, in your first location block:

location / {
       root   /srv/nginx/www/nginx_htdocs/;
       index  index.html index.htm index.php;
       try_files $uri $uri/ /index.php?$request_uri;
    }

This way, if

`http://mysite.com/xyz` 

doesn't match any file or folder, it gets handed to index.php in the form of

`http://mysite.com/index.php?xyz` 
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top