I installed nginx + php + drupal 7 at my windows 7 for test . But i cannot turn on drupal 7 clean url , i search answer from many webiste but still cannot turn clean url on , So please help me out !!!!!!!
the following is my nginx rewrite :
location / {
root E:\www-test\mywwwroot\drupal-7.0;
index index.php index.html index.htm;
# the main drupal app
if (!-e $request_filename) {
rewrite ^/(.*)$ /index.php?q=$1 last;
}
}
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;
}
Re: ask help for clean URL ? anyone can help me out ???
你打開 .htaccess 對一對比這行你便明白 (或對一對 D6 / D7 的也會明白)
rewrite ^/(.*)$ /index.php?q=$1 last;
** 看不懂中文,請告訴我,LOL
---
notaBlueScreen
Re: ask help for clean URL ? anyone can help me out ???
nginx是没有 .htaccess 的。。。
Re: ask help for clean URL ? anyone can help me out ???
但是 Drupal 是有的 :)
---
notaBlueScreen
Re: ask help for clean URL ? anyone can help me out ???
但哪是只为apache的吧。不是for nginx的啊??
Re: ask help for clean URL ? anyone can help me out ???
要你比較,不是使用 :)
算了,直接告訴你
D6
RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]
D7
RewriteRule ^ index.php [L]
nginx D6
rewrite ^/(.*)$ /index.php?q=$1 last;
那 nginx D7 是....
(你看懂的)
---
notaBlueScreen
Re: ask help for clean URL ? anyone can help me out ???
多谢 notaBlueScreen 你的指教, 我想问一问,你说的哪个rewrite是要加入到NGINX的conf文件内吗? 还是在什么地方? 可否贴一个完整的出来给我看下,小弟已对这个NGINX drupal 7 的 rewrite烦了两天,网上好多方案都是在NGINX的conf文件内加一些规则,但我试过都没用,无论是将druapl安装在子文件夹还是主目录,暂时我是放在子目录的。。 我网站的主目录是 E:\www-test\mywwwroot 。 drupal放在 E:\www-test\mywwwroot\drupal-7.0 内。。。
Re: ask help for clean URL ? anyone can help me out ???
抄你上面一段,大概是長成這樣:
location /d7/ {
root E:\www-test\mywwwroot\drupal-7.0;
index index.php index.html index.htm;
# the main drupal app
if (!-e $request_filename) {
rewrite ^ /d7/index.php last;
break;
}
}
---
notaBlueScreen
Re: ask help for clean URL ? anyone can help me out ???
多谢你,我试一试先。。。。稍后回复你。
Re: ask help for clean URL ? anyone can help me out ???
notaBlueScreen,你好. 我试过都是不能启动Drupal 7的 CLEAN URL, 我按了run test url clean后,一样没有哪个启的动的选择项出来? 请问我的nginx到底是什么地方错了。。。。麻烦你。。
Re: ask help for clean URL ? anyone can help me out ???
你該不會照直複製吧 ??
也該不會沒有重啟吧 ?
更不會沒有啟用 rewrite 吧 ??
這樣解決不了,你複雜你整份 conf 出來看看
直接試試:
http://example.com/d7/admin/config/
看是什麼 error
或打啟 nginx rewrite_log 看
---
notaBlueScreen
Re: ask help for clean URL ? anyone can help me out ???
我贴上了nginx的conf文件, 我的网站主目录是 E:\www-test\mywwwroot\ , 我将我的drupal7放在 E:\www-test\mywwwroot\drupal-7.0 内。。
localhost:8087是直接读取网站主目录E:\www-test\mywwwroot\ 的, 我再新开了个网站localhost:8077,并将其的主目录设为E:\www-test\mywwwroot\drupal-7.0
我在网上找到,如drupal放在主或次目录的话,Nginx的rewrite应写成如下:
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文件,请帮手看一看,如要变的话,请指出哪部分,并要变成什么样。本人刚学nginx,对这些所谓的rewrite并不是太了解,请帮手,多谢。。。
#user nobody;
worker_processes 1;
error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#pid logs/nginx.pid;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
#log_format main '$remote_addr - $remote_user [$time_local] "$request" '
# '$status $body_bytes_sent "$http_referer" '
# '"$http_user_agent" "$http_x_forwarded_for"';
#access_log logs/access.log main;
sendfile on;
#tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 65;
gzip on;
server {
listen 8078;
server_name localhost;
if ($request_uri ~* ^.*/.*$) {
rewrite ^/(\w*)/(.*)$ /$1/index.php?q=$2 last;
break;
}
autoindex on;
######### 当网站没有默认文件时,打开域名可以看到文件目录结构
#charset koi8-r;
#access_log logs/host.access.log main;
location / {
root E:\www-test\mywwwroot;
index index.php index.html index.htm;
# 实现伪静态的地方,如果不是物理文件,则使用下面的定义
# last 就表示这是最后一条处理命令,如果匹配,下面的不管了
if ($request_uri ~* ^.*/.*$) {
rewrite ^/(\w*)/(.*)$ /$1/index.php?q=$2 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-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;
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;
#}
}
}
Re: ask help for clean URL ? anyone can help me out ???
补充一下,我每次保存完nginx的conf文件后,都会用
taskkill /f /im nginx.exe
taskkill /f /im php-cgi.exe
停止nginx,
再重新开动NGINX的。
Re: ask help for clean URL ? anyone can help me out ???
我沒測試,但應該可行
留意 {} 有沒有多了或少了的問題
#user nobody;
worker_processes 1;
error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#pid logs/nginx.pid;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
#log_format main '$remote_addr - $remote_user [$time_local] "$request" '
# '$status $body_bytes_sent "$http_referer" '
# '"$http_user_agent" "$http_x_forwarded_for"';
#access_log logs/access.log main;
sendfile on;
#tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 65;
gzip on;
server {
listen 8078;
server_name localhost;
autoindex on;
######### 当网站没有默认文件时,打开域名可以看到文件目录结构
#charset koi8-r;
#access_log logs/host.access.log main;
location / {
root E:\www-test\mywwwroot;
index index.php index.html index.htm;
# 实现伪静态的地方,如果不是物理文件,则使用下面的定义
# last 就表示这是最后一条处理命令,如果匹配,下面的不管了
if ($request_uri ~* ^.*/.*$) {
rewrite ^/(\w*)/(.*)$ /$1/index.php?q=$2 last;
break;
}
}
location /drupal-7.0/ {
index index.php index.html;
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-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;
#}
}
---
notaBlueScreen
Re: ask help for clean URL ? anyone can help me out ???
都是不行,当我进入到 http://localhost:8078/drupal-7.0/ 后,不要说URL CLEAN不能启动(与原来一样),并且站点的CSS与图片全部都不能加载,估计是哪些rewrite规则重定向了什么地方了,请协助,多谢你的热情帮助。
Re: ask help for clean URL ? anyone can help me out ???
這樣呢
#user nobody;
worker_processes 1;
error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#pid logs/nginx.pid;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
#log_format main '$remote_addr - $remote_user [$time_local] "$request" '
# '$status $body_bytes_sent "$http_referer" '
# '"$http_user_agent" "$http_x_forwarded_for"';
#access_log logs/access.log main;
sendfile on;
#tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 65;
gzip on;
server {
listen 8078;
server_name localhost;
root E:\www-test\mywwwroot;
autoindex on;
location /drupal-7.0/ {
index index.php index.html;
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$ {
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;
#}
}
---
notaBlueScreen
Re: ask help for clean URL ? anyone can help me out ???
图与CSS可看到了,但还是不能启动CLEAN URL,按完run the clean url test后,都是没反应,选项出不来,请问你有没试过在WINDOWS上试过用nginx加drupal起动clean url,因我见网上的方法我都用过了,但都不能,不知是否它们是在LINUX上试,不过按我的理解,应与系统没关的。。。
error.log:
2011/01/19 19:00:17 [error] 3464#4368: *15 CreateFile() "E:\www-test\mywwwroot\drupal-7.0/admin/config/search/clean-urls/check" failed (3: The system cannot find the path specified), client: 127.0.0.1, server: localhost, request: "GET /admin/config/search/clean-urls/check HTTP/1.0", host: "localhost:8077"
2011/01/19 19:00:58 [error] 4876#3008: *4 CreateFile() "E:\www-test\mywwwroot\drupal-7.0/admin/config/search/clean-urls/check" failed (3: The system cannot find the path specified), client: 127.0.0.1, server: localhost, request: "GET /admin/config/search/clean-urls/check HTTP/1.0", host: "localhost:8077"
2011/01/19 19:01:33 [error] 4876#3008: *8 CreateFile() "E:\www-test\mywwwroot\drupal-7.0/admin/config/search/clean-urls/check" failed (3: The system cannot find the path specified), client: 127.0.0.1, server: localhost, request: "GET /admin/config/search/clean-urls/check HTTP/1.0", host: "localhost:8077"
2011/01/19 19:02:04 [error] 4876#3008: *11 CreateFile() "E:\www-test\mywwwroot\drupal-7.0/admin/config/search/clean-urls/check" failed (3: The system cannot find the path specified), client: 127.0.0.1, server: localhost, request: "GET /admin/config/search/clean-urls/check HTTP/1.0", host: "localhost:8077"
2011/01/19 20:53:21 [error] 7724#1852: *1 CreateFile() "E:\www-test\mywwwroot/favicon.ico" failed (2: The system cannot find the file specified), client: 127.0.0.1, server: localhost, request: "GET /favicon.ico HTTP/1.1", host: "localhost:8078"
access.log:
127.0.0.1 - - [19/Jan/2011:21:10:32 +0800] "GET /drupal-7.0/themes/seven/style.css?lf44wv HTTP/1.1" 200 18314 "http://localhost:8078/drupal-7.0/?q=admin%2Fconfig%2Fsearch%2Fclean-urls..." "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; InfoPath.3; .NET4.0C; .NET4.0E; Tablet PC 2.0)"
127.0.0.1 - - [19/Jan/2011:21:10:32 +0800] "GET /drupal-7.0/themes/seven/ie.css?lf44wv HTTP/1.1" 200 360 "http://localhost:8078/drupal-7.0/?q=admin%2Fconfig%2Fsearch%2Fclean-urls..." "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; InfoPath.3; .NET4.0C; .NET4.0E; Tablet PC 2.0)"
127.0.0.1 - - [19/Jan/2011:21:10:32 +0800] "GET /drupal-7.0/modules/system/system.js?lf44wv HTTP/1.1" 200 4941 "http://localhost:8078/drupal-7.0/?q=admin%2Fconfig%2Fsearch%2Fclean-urls..." "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; InfoPath.3; .NET4.0C; .NET4.0E; Tablet PC 2.0)"
127.0.0.1 - - [19/Jan/2011:21:10:32 +0800] "GET /drupal-7.0/modules/overlay/overlay-child.js?v=1.0 HTTP/1.1" 200 6688 "http://localhost:8078/drupal-7.0/?q=admin%2Fconfig%2Fsearch%2Fclean-urls..." "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; InfoPath.3; .NET4.0C; .NET4.0E; Tablet PC 2.0)"
127.0.0.1 - - [19/Jan/2011:21:10:32 +0800] "GET /drupal-7.0/themes/seven/images/buttons.png HTTP/1.1" 200 786 "http://localhost:8078/drupal-7.0/?q=admin%2Fconfig%2Fsearch%2Fclean-urls..." "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; InfoPath.3; .NET4.0C; .NET4.0E; Tablet PC 2.0)"
127.0.0.1 - - [19/Jan/2011:21:10:33 +0800] "GET /drupal-7.0/modules/overlay/images/close.png HTTP/1.1" 200 344 "http://localhost:8078/drupal-7.0/?q=admin%2Fconfig%2Fsearch%2Fclean-urls..." "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; InfoPath.3; .NET4.0C; .NET4.0E; Tablet PC 2.0)"
127.0.0.1 - - [19/Jan/2011:21:10:33 +0800] "GET /drupal-7.0/modules/shortcut/shortcut.png HTTP/1.1" 200 432 "http://localhost:8078/drupal-7.0/?q=admin%2Fconfig%2Fsearch%2Fclean-urls..." "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; InfoPath.3; .NET4.0C; .NET4.0E; Tablet PC 2.0)"
127.0.0.1 - - [19/Jan/2011:21:11:05 +0800] "GET /drupal-7.0/admin/config/search/clean-urls/check HTTP/1.0" 499 0 "-" "Drupal (+http://drupal.org/)"
127.0.0.1 - - [19/Jan/2011:21:11:05 +0800] "POST /drupal-7.0/?q=admin%2Fconfig%2Fsearch%2Fclean-urls&render=overlay&render=overlay HTTP/1.1" 302 5 "http://localhost:8078/drupal-7.0/?q=admin%2Fconfig%2Fsearch%2Fclean-urls..." "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; InfoPath.3; .NET4.0C; .NET4.0E; Tablet PC 2.0)"
127.0.0.1 - - [19/Jan/2011:21:11:35 +0800] "GET /drupal-7.0/admin/config/search/clean-urls/check HTTP/1.0" 499 0 "-" "Drupal (+http://drupal.org/)"
127.0.0.1 - - [19/Jan/2011:21:11:35 +0800] "GET /drupal-7.0/?q=admin/config/search/clean-urls&render=overlay HTTP/1.1" 200 2589 "http://localhost:8078/drupal-7.0/?q=admin%2Fconfig%2Fsearch%2Fclean-urls..." "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; InfoPath.3; .NET4.0C; .NET4.0E; Tablet PC 2.0)"
Re: ask help for clean URL ? anyone can help me out ???
你用 NGINX 版本多少,我試一試
---
notaBlueScreen
Re: ask help for clean URL ? anyone can help me out ???
我用的是 nginx-0.8.54 php-5.3.5 windows 7 系统,麻烦你了。。。。
Re: ask help for clean URL ? anyone can help me out ???
可以啊,幾乎沒有不同,也沒有多餘設定,就是純粹地下載
#user nobody;
worker_processes 1;
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#pid logs/nginx.pid;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
#log_format main '$remote_addr - $remote_user [$time_local] "$request" '
# '$status $body_bytes_sent "$http_referer" '
# '"$http_user_agent" "$http_x_forwarded_for"';
#access_log logs/access.log main;
sendfile on;
#tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 65;
#gzip on;
server {
listen 80;
server_name localhost;
#charset koi8-r;
#access_log logs/host.access.log main;
root C:/w/www;
location / {
index index index.html index.htm index.php;
}
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 /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$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME C:/w/www$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;
#}
}
# another virtual host using mix of IP-, name-, and port-based configuration
#
#server {
# listen 8000;
# listen somename:8080;
# server_name somename alias another.alias;
# location / {
# root html;
# index index.html index.htm;
# }
#}
# HTTPS server
#
#server {
# listen 443;
# server_name localhost;
# ssl on;
# ssl_certificate cert.pem;
# ssl_certificate_key cert.key;
# ssl_session_timeout 5m;
# ssl_protocols SSLv2 SSLv3 TLSv1;
# ssl_ciphers ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP;
# ssl_prefer_server_ciphers on;
# location / {
# root html;
# index index.html index.htm;
# }
#}
}
---
notaBlueScreen
Re: ask help for clean URL ? anyone can help me out ???
我将你的文件变成如下的这样,在我的机上,都是不能啊
我只是将root 设回我的 E:\www-test\mywwwroot
请问你可否尝试一下,按我的E:\www-test\mywwwroot在你的电脑上试一试。。。
#user nobody;
worker_processes 1;
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#pid logs/nginx.pid;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
#log_format main '$remote_addr - $remote_user [$time_local] "$request" '
# '$status $body_bytes_sent "$http_referer" '
# '"$http_user_agent" "$http_x_forwarded_for"';
#access_log logs/access.log main;
sendfile on;
#tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 65;
#gzip on;
server {
listen 80;
server_name localhost;
#charset koi8-r;
#access_log logs/host.access.log main;
root E:\www-test\mywwwroot;
location / {
index index index.html index.htm index.php;
}
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 /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$ {
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;
#}
}
# another virtual host using mix of IP-, name-, and port-based configuration
#
#server {
# listen 8000;
# listen somename:8080;
# server_name somename alias another.alias;
# location / {
# root html;
# index index.html index.htm;
# }
#}
# HTTPS server
#
#server {
# listen 443;
# server_name localhost;
# ssl on;
# ssl_certificate cert.pem;
# ssl_certificate_key cert.key;
# ssl_session_timeout 5m;
# ssl_protocols SSLv2 SSLv3 TLSv1;
# ssl_ciphers ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP;
# ssl_prefer_server_ciphers on;
# location / {
# root html;
# index index.html index.htm;
# }
#}
}
Re: ask help for clean URL ? anyone can help me out ???
你可以弄成像我一樣.....
你有沒有試過登出後重新登入試
或直接
eeee.com/node/1
也可以在 settings.php 強制打開
$conf['clean_url'] = 1
(應該沒記錯)
---
notaBlueScreen
Re: ask help for clean URL ? anyone can help me out ???
好的,我下午回家试一试先。多谢你。
Re: ask help for clean URL ? anyone can help me out ???
我刚看了一下 在sites\default\settings.php 中并没有所谓的$conf['clean_url'] 可设,你意思是加$conf['clean_url']=1进去吗?
另外,直接用eeee.com/node/1或者将目录变成与你一样,我要下午回家才可试到,我会较后回复你结果的,多谢晒你的帮助。。。
Re: ask help for clean URL ? anyone can help me out ???
你最好將無關的 conf 刪除,以免相撞
看清楚是否正常重啟了 nginx (重啟它,不要 reload conf)
打開 debug
error_log /xxxxxxxxxxxxxxxxxxxxxxxxx/logs/error.log notice;
rewrite_log on;
---
notaBlueScreen
Re: ask help for clean URL ? anyone can help me out ???
我只有一个CONF的,就是之前贴出来的文件, 我不是用RELOAD的,我是停了再重开的。好似你给我的文件是用80 port的,我本来是用8077 port, 我重起nginx后,就可用80访问了,所以这方面应OK的。。
至于打开LOG的话,我下午回去试一试,再回复你。
Re: ask help for clean URL ? anyone can help me out ???
我已将目录移动 C:\w\www\drupal-7.0 并用你的CONF文件,全部照抄,只是加了打开rewrite log的两句。 但一样不行。。以下是我的rewrite error log文件的内容:
另外,我试过用http://localhost/drupal-7.0/node/1 是可打开我的网页的。
我试过将我的第一个文章的URL alias设成test 接着用http://localhost/drupal-7.0/test打开,一样可行。看上去好似是rewrite成功打开一样,请给予意见。
2011/01/20 18:38:03 [error] 6728#4296: *1 directory index of "C:/w/www/" is forbidden, client: 127.0.0.1, server: localhost, request: "GET / HTTP/1.1", host: "localhost"
2011/01/20 18:38:38 [notice] 6728#4296: *8 "^" matches "/drupal-7.0/admin/config/search/clean-urls/check", client: 127.0.0.1, server: localhost, request: "GET /drupal-7.0/admin/config/search/clean-urls/check HTTP/1.0", host: "localhost"
2011/01/20 18:38:38 [notice] 6728#4296: *8 rewritten data: "/drupal-7.0/index.php", args: "", client: 127.0.0.1, server: localhost, request: "GET /drupal-7.0/admin/config/search/clean-urls/check HTTP/1.0", host: "localhost"
2011/01/20 18:39:11 [notice] 6728#4296: *11 "^" matches "/drupal-7.0/admin/config/search/clean-urls/check", client: 127.0.0.1, server: localhost, request: "GET /drupal-7.0/admin/config/search/clean-urls/check HTTP/1.0", host: "localhost"
2011/01/20 18:39:11 [notice] 6728#4296: *11 rewritten data: "/drupal-7.0/index.php", args: "", client: 127.0.0.1, server: localhost, request: "GET /drupal-7.0/admin/config/search/clean-urls/check HTTP/1.0", host: "localhost"
2011/01/20 18:39:42 [notice] 6728#4296: *14 "^" matches "/drupal-7.0/admin/config/search/clean-urls/check", client: 127.0.0.1, server: localhost, request: "GET /drupal-7.0/admin/config/search/clean-urls/check HTTP/1.0", host: "localhost"
2011/01/20 18:39:42 [notice] 6728#4296: *14 rewritten data: "/drupal-7.0/index.php", args: "", client: 127.0.0.1, server: localhost, request: "GET /drupal-7.0/admin/config/search/clean-urls/check HTTP/1.0", host: "localhost"
Re: ask help for clean URL ? anyone can help me out ???
补充一下: 现在是可以用http://localhost:8078/drupal-7.0/test 这类方式打开网站,但是DRUPAL是没办法显示出可以起用CLEAN URL的按键的,我估计是DRUPAL问题,拿回了以前测试用的XAMMP(apache php mysql)来使用同一个DRUPAL程式,但是可以打开启动CLEAN URL的选项的,所以现在我估计问题都是集中在NGINX上吧,请帮手看看我上一个贴的REWRITE LOG,多谢你先。
Re: ask help for clean URL ? anyone can help me out ???
你的 logs 很正常呢,你有沒有修改過 ?? (這沒有 ERROR 呢,即是說請求結果正常)
你試試直接 http://example.com/drupal-7.0/admin/config/search/clean-urls/check
應該會下載一個檔案,內容是:
{"status":true}
如果是 FALSE,這可能偏向 drupal 問題多了
---
notaBlueScreen
Re: ask help for clean URL ? anyone can help me out ???
我快速看看代碼,可以乏略我說的
因為只要有番回就一定是 true,沒有就 err 404
---
notaBlueScreen
Re: ask help for clean URL ? anyone can help me out ???
我下载了,内容是 {"status":true}。。。。 ,所以还是确定不了问题所在。。
Re: ask help for clean URL ? anyone can help me out ???
你好 notabluescreen , 我最后只能在Drupal的settings.php中设置$conf['clean_url']=1; 这样这个选项才可打开。 多谢你的帮助。我已将我的笔记写在我的BLOG上了,http://blog.sina.com.cn/s/blog_48a770da0100nwgf.html
Re: ask help for clean URL ? anyone can help me out ???
好的,有兩個有少少關係的補丁正在進行中,或者 D7.1 時可以再試試
是了...
经过台湾网友notaBlueScreen
我來自香港 :)
---
notaBlueScreen
Re: ask help for clean URL ? anyone can help me out ???
好的,多谢你
Re: ask help for clean URL ? anyone can help me out ???
我的 nginx rewrite rules
server {
...略
root /home/www/drupal;
location / {
try_files $uri $uri/ @drupal_root;
}
location @drupal_root {
rewrite ^/(.*)$ /index.php?q=$1;
}
location @drupal_subdir {
rewrite ^/(\w*)/(.*)$ /$1/index.php?q=$2;
}
}
如果你的網站是在第一層目錄下
如 http://example.com/drupal/
try_files $uri $uri/ @drupal_root;
改成
try_files $uri $uri/ @drupal_subdir;
減少 if 判斷式對效能比較沒影響^^
Re: ask help for clean URL ? anyone can help me out ???
你好 yelban 朋友, 哪我的 rewirete可写成这样吗?请指教。
server {
...略
root /home/www/;
#注这个网站的drupal是放在第一層目錄下
location / {
try_files $uri $uri/ @drupal_subdir;
}
location @drupal_subdir {
rewrite ^/(\w*)/(.*)$ /$1/index.php?q=$2;
}
l
}
另外一个是drupal是放在主目錄下,另一个server的 rewirte如下:
server {
...略
root /home/www/drupal;
location / {
try_files $uri $uri/ @drupal_root;
}
location @drupal_root {
rewrite ^/(.*)$ /index.php?q=$1;
}
}
Re: ask help for clean URL ? anyone can help me out ???
假設你的網址沒有子目錄
網站根目錄的檔案路徑是 /home/www
網址 http://example.com/(index.php)
drupal 的 index.php 路徑就是 /home/www/index.php
這時應該用 @drupal_root
try_files $uri $uri/ @drupal_root;
如果是網址有子目錄形式的
ex. http://example.com/another/(index.php)
實際檔案路徑是 /home/www/another(/index.php)
就要用 @drupal_subdir
try_files $uri $uri/ @drupal_subdir;
Re: ask help for clean URL ? anyone can help me out ???
我试过将网站放在子目录,但当我用如下设定时,http://localhost:8078/drupal-7.0/ 只会列出文件,不会找到index.php
server {
listen 8078;
server_name localhost;
root E:\www-test\mywwwroot ;
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 = / {
index index.php;
}
location / {
try_files $uri $uri/ @drupal_subdir;
}
location @drupal_subdir {
rewrite ^/(\w*)/(.*)$ /$1/index.php?q=$2;
}
Re: ask help for clean URL ? anyone can help me out ???
location 好像不能重複,
location = / {
}
要不試試看? 把index 拉到 location 外面, 只留一組 根目錄 location 設定
server {
...略
index index.php;
location / {
try_files $uri $uri/ @drupal_subdir;
}
...
}
Re: ask help for clean URL ? anyone can help me out ???
按你的意思试过了,可打开http://localhost:8078/drupal-7.0/ ,但一进简洁的URL(例如: http://localhost:8078/drupal-7.0/test )就提示404 Not Found
。
Re: ask help for clean URL ? anyone can help me out ???
try try see
location ~ \.php$ {
...略
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
Re: ask help for clean URL ? anyone can help me out ???
你好yelban,我现在的情况是 网站主目录在E:\www-test\mywwwroot ,其下有一个 drupal-7.0的目录是放drupal的, 我的主网站的root 是设在 E:\www-test\mywwwroot , 所以如通过打开drupal-7.0并显示正常的话,以下是我的nginx conf 内的server文件, 我怕抄你部分再变来变去会出现都是不能正常打开URL CLEAN的情况,所以我先将我的 nginx conf给你看,如你要变的话,直接变好,贴上来,我全部抄上去试下,如OK的话,我再对比不同点,这样比较好吧。
server {
listen 8078;
server_name localhost;
error_log logs/erro-for-rewriter-my-main8078.log notice;
rewrite_log on;
root E:\www-test\mywwwroot ;
autoindex on;
######### 当网站没有默认文件时,打开域名可以看到文件目录结构
#charset koi8-r;
access_log logs/my-main8078.log ;
location = / {
index index.php;
}
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-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;
#}
}
Re: ask help for clean URL ? anyone can help me out ???
你好yelban,我现在的情况是 网站主目录在E:\www-test\mywwwroot ,其下有一个 drupal-7.0的目录是放drupal的, 我的主网站的root 是设在 E:\www-test\mywwwroot , 所以如通过打开drupal-7.0并显示正常的话,以下是我的nginx conf 内的server文件, 我怕抄你部分再变来变去会出现都是不能正常打开URL CLEAN的情况,所以我先将我的 nginx conf给你看,如你要变的话,直接变好,贴上来,我全部抄上去试下,如OK的话,我再对比不同点,这样比较好吧。
server {
listen 8078;
server_name localhost;
error_log logs/erro-for-rewriter-my-main8078.log notice;
rewrite_log on;
root E:\www-test\mywwwroot ;
autoindex on;
######### 当网站没有默认文件时,打开域名可以看到文件目录结构
#charset koi8-r;
access_log logs/my-main8078.log ;
location = / {
index index.php;
}
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-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;
#}
}
Re: ask help for clean URL ? anyone can help me out ???
try_files 其實是取代這部份
if (-f $request_filename) {
expires 30d;
break;
}
if (!-e $request_filename) {
rewrite ^ /drupal-7.0/index.php last;
break;
}
大多情況下差異不大 :)
---
notaBlueScreen
Re: ask help for clean URL ? anyone can help me out ???
但yelban说要试下
try try see
location ~ \.php$ {
...略
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
哪到底与 fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; 有没关系啊。?????
Re: ask help for clean URL ? anyone can help me out ???
但yelban说要试下
try try see
location ~ \.php$ {
...略
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
哪到底与 fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; 有没关系啊。?????
Re: ask help for clean URL ? anyone can help me out ???
因為你也要有一個東西來處理 PHP
---
notaBlueScreen
Re: ask help for clean URL ? anyone can help me out ???
我试过将 E:\www-test\mywwwroot$fastcgi_script_name; 变成 $document_root$fastcgi_script_name; 发现运行不了PHP的文件
Re: ask help for clean URL ? anyone can help me out ???
我试过将 E:\www-test\mywwwroot$fastcgi_script_name; 变成 $document_root$fastcgi_script_name; 发现运行不了PHP的文件