1024programmer Nginx Drupal7’s cleanurl and Nginx pseudo-static rules

Drupal7’s cleanurl and Nginx pseudo-static rules

My website main directory is E:\www-test\mywwwroot\ , I put my drupal7 in
E:\www-test\mywwwroot\drupal-7.0. .

localhost:8087 directly reads the main directory of the website E:\www-test\mywwwroot\,
I opened a new website localhost:8077, and set its main directory to E:\www-test\mywwwroot\drupal-7.0

There are tutorials online that say

If Drupal is installed in the root directory,

1

2

3

4

if (!-e $request_filename) {

rewrite ^/(.*)$
/index.php?q=$1 last;

break;

}

if drupal is in a subdirectory,

1

2

3

4

if ($request_uri ~* ^.*/.*$) {

rewrite ^/(\w*)/(.*)$ /$1/index.php?q=$2 last;

break;

}

But the conf file of nginx is set as:

server {

listen
8078;

server_name www.server110.com;

error_log logs/erro-for-rewriter-8078.log
notice;

rewrite_log on;

autoindex on;

######### When the website does not have a default file, open the domain name to see the file directory structure

#charset
koi8-r;

#access_log
logs/host.access.log main;

location /drupal-7.0/ {

index index index.html index.htm
index.php;

if (-f $request_filename) {

expires 30d;

break;

}

if (!-e $request_filename) {

rewrite ^ /drupal-7.0/index.php last;

break;

}

}

#error_page 404 /index.php;

# 404
Hand over to 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 html;

}

#
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
E:\www-test\mywwwroot;

fastcgi_pass 127.0.0.1:9000;

fastcgi_index index.php;

fastcgi_param SCRIPT_FILENAME
E:\www-test\mywwwroot$fastcgi_script_name;

include
fastcgi_params;

}

# deny
access to .htaccess files, if Apache’s document root

#
concurs with nginx’s one

#

#location ~ /\.ht {

#
deny all;

#}

}

###############################################
###############################################

server {

client_max_body_size 25m;

client_body_buffer_size 128k;

listen
8077;

server_name
localhost;

root
E:\www-test\mywwwroot\drupal-7.0;

#upload_max_file_size 25M;

charset utf-8;

#
access_log
/var/www/www.soa.tw/logs/access.log;

# error_log /var/www/www.soa.tw/logs/error.log;

error_log logs/erro-for-rewriter-8077.log
notice;

rewrite_log on;

location = / {

index index.php;

}

location / {

index index.php
index.html;

if (!-f $request_filename) {

rewrite
^(.*)$ /index.php?q=$1 last;

break;

}

if (!-d $request_filename) {

rewrite
^(.*)$ /index.php?q=$1 last;

break;

}

}

error_page 404

/index.php;

#
serve static files directly

location ~* ^.+\.(jpg|jpeg|gif|css|png|js|ico)$ {

access_log
off;

expires
30d;

break;

}

#
redirect server error pages to the static page /50x.html

#

error_page 500 502 503 504
/50x.html;

location = /50x.html {

root html;

}

location ~ \.php$
{

root
E:\www-test\mywwwroot\drupal-7.0;

fastcgi_pass 127.0.0.1:9000;

fastcgi_index index.php;

fastcgi_param SCRIPT_FILENAME
E:\www-test\mywwwroot\drupal-7.0$fastcgi_script_name;

include
fastcgi_params;

}

# deny
access to .htaccess files, if Apache’s document root

#
concurs with nginx’s one

#

#location ~ /\.ht {

#
deny all;

#}

}

Through the above settings, I can access my DRUPAL with a simple URL, such as http://localhost:8077/test
Or eeee.com/node/1 , but still can’t open clean on DRUPAL
url option, and finally only set $conf[‘clean_url’]=1 in Drupal’s settings.php;
Only then will this option be turned on.

p>

error_page 500 502 503 504
/50x.html;

location = /50x.html {

root html;

}

location ~ \.php$
{

root
E:\www-test\mywwwroot\drupal-7.0;

fastcgi_pass 127.0.0.1:9000;

fastcgi_index index.php;

fastcgi_param SCRIPT_FILENAME
E:\www-test\mywwwroot\drupal-7.0$fastcgi_script_name;

include
fastcgi_params;

}

# deny
access to .htaccess files, if Apache’s document root

#
concurs with nginx’s one

#

#location ~ /\.ht {

#
deny all;

#}

}

Through the above settings, I can access my DRUPAL with a simple URL, such as http://localhost:8077/test
Or eeee.com/node/1 , but still can’t open clean on DRUPAL
url option, and finally only set $conf[‘clean_url’]=1 in Drupal’s settings.php;
Only then will this option be turned on.

This article is from the internet and does not represent1024programmerPosition, please indicate the source when reprinting:https://www.1024programmer.com/drupal7s-cleanurl-and-nginx-pseudo-static-rules/

author: admin

Previous article
Next article

Leave a Reply

Your email address will not be published. Required fields are marked *

Contact Us

Contact us

181-3619-1160

Online consultation: QQ交谈

E-mail: [email protected]

Working hours: Monday to Friday, 9:00-17:30, holidays off

Follow wechat
Scan wechat and follow us

Scan wechat and follow us

Follow Weibo
Back to top
首页
微信
电话
搜索