drupal7如何在nginx下设置呢?

天南海北 发布于 2013/08/02 15:30
阅读 1K+
收藏 0
请问,我照着http://wiki.nginx.org/Drupal这样设置,为什么还是有?q=xxxx/xxxx的URL形式呢?我想去掉?q=的这几个字符,请问如何做呢?
server {
        server_name www.test-1.com;
        root /home/wwwroot/drupal;

        gzip_static on;
        if (!-f $request_filename) {
                rewrite  ^(.*)$  /index.php?q=$1  last;
                break;
        }

        if (!-d $request_filename) {
                rewrite  ^(.*)$  /index.php?q=$1  last;
                break;
        }

        location = /favicon.ico {
                log_not_found off;
                access_log off;
        }

        location = /robots.txt {
                allow all;
                log_not_found off;
                access_log off;
        }


        location ~* \.(txt|log)$ {
                allow 192.168.0.0/16;
                deny all;
        }

        location ~ \..*/.*\.php$ {
                return 403;
        }

        location ~ ^/sites/.*/private/ {
                return 403;
        }
        location ~ (^|/)\. {
                return 403;
        }

        location / {
                # This is cool because no php is touched for static content
                try_files $uri @rewrite ;
        }

        location @rewrite {
                # You have 2 options here
                # For D7 and above:
                # Clean URLs are handled in drupal_environment_initialize().
                rewrite ^ /index.php;
                # For Drupal 6 and bwlow:
                # Some modules enforce no slash (/) at the end of the URL
                # Else this rewrite block wouldn't be needed (GlobalRedirect)
                #rewrite ^/(.*)$ /index.php?q=$1;
        }

        location ~ \.php$ {
                fastcgi_split_path_info ^(.+\.php)(/.+)$;
                #NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini
                include fastcgi_params;
                fastcgi_param SCRIPT_FILENAME $request_filename;
                fastcgi_intercept_errors on;
                fastcgi_pass unix:/tmp/phpfpm.sock;
        }

        # Fighting with Styles? This little gem is amazing.
        # This is for D6
        #location ~ ^/sites/.*/files/imagecache/ {
        # This is for D7 and D8
        location ~ ^/sites/.*/files/styles/ {
                try_files $uri @rewrite ;
        }

        location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
                expires max;
                log_not_found off;
        }
}

加载中
0
黄冠能
黄冠能
试试这个页面的方法:https://drupal.org/node/976392,我可以的
黄冠能
黄冠能
我是在Drupal管理菜单里启用Clean URL的,我还不知道可以在setting里启用。
天南海北
天南海北
回复 @黄冠能 : 我在settings.php加了$conf['url_clean']=1,然后在nginx.conf加了那个rewrite才可以的。 Linux系统
黄冠能
黄冠能
没改settings.php,就按照那个页面的说明改了几行。
天南海北
天南海北
你没改settings.php这个文件吗?
0
fantasy0707
fantasy0707
http://www.turen.me/archives/460   这里很可行,我测试了
返回顶部
顶部