我的网站主目录是 E:www-testmywwwroot , 我将我的drupal7放在 E:www-testmywwwrootdrupal-7.0 内。。
localhost:8087是直接读取网站主目录E:www-testmywwwroot 的, 我再新开了个网站localhost:8077,并将其的主目录设为E:www-testmywwwrootdrupal-7.0
网上有教程说
If Drupal install in the root directory,
1 2 3 4 |
if (!-e $request_filename) { rewrite ^/(.*)$ /index.php?q=$1 last; break; } |
if drupal in a subdirectory,
1 2 3 4 |
if ($request_uri ~* ^.*/.*$) { rewrite ^/(w*)/(.*)$ /$1/index.php?q=$2 last; break; } |
但的的nginx的conf的文件是设成:
server {
listen 8078;
server_name www.server110.com;
error_log logs/erro-for-rewriter-8078.log notice;
rewrite_log on;
autoindex on;
######### 当网站没有默认文件时,打开域名可以看到文件目录结构
#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 交给 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-testmywwwroot;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME E:www-testmywwwroot$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-testmywwwrootdrupal-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-testmywwwrootdrupal-7.0;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME E:www-testmywwwrootdrupal-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;
#}
}
通过以上设定,就开用简洁URL访问我的DRUPAL,例如http://localhost:8077/test 或eeee.com/node/1 ,但是还是在DRUPAL上打不开clean url选项,最后只能在Drupal的settings.php中设置$conf['clean_url']=1; 这样这个选项才可打开。
声明: 此文观点不代表本站立场;转载须要保留原文链接;版权疑问请联系我们。