1
yeyeye 2016-06-20 23:45:47 +08:00
很显然 把规则发出来
|
2
2232588429 OP @yeyeye
if (-d $request_filename){ rewrite ^/(.*)([^/])$ /$1$2/ permanent; } if (-f $request_filename/index.html){ rewrite (.*) $1/index.html break; } if (-f $request_filename/index.php){ rewrite (.*) $1/index.php; } if (!-f $request_filename){ rewrite (.*) /index.php; } |
3
yeyeye 2016-06-21 00:20:53 +08:00
@2232588429 我不会改 我的意思是 你发出来 别人顺手就帮你了
|
4
seki 2016-06-21 00:27:24 +08:00
改一下 try_files 的设置再在 wp 中设置一下就好了,为什么会有这么多 if
|
5
seki 2016-06-21 00:28:46 +08:00
|
6
2232588429 OP @seki 改后成 404 了~
|
7
lslqtz 2016-06-21 01:59:37 +08:00
附上本人配置文件。
#user nobody; worker_processes 1; events { worker_connections 1024; } http { include mime.types; default_type application/octet-stream; sendfile on; keepalive_timeout 600; client_max_body_size 128m; server_names_hash_bucket_size 64; fastcgi_connect_timeout 300s; fastcgi_send_timeout 300s; fastcgi_read_timeout 300s; fastcgi_buffer_size 128k; fastcgi_buffers 8 128k; fastcgi_busy_buffers_size 256k; fastcgi_temp_file_write_size 256k; fastcgi_intercept_errors on; gzip on; gzip_comp_level 9; gzip_types text/plain text/css application/javascript; server { listen 80; return 403; } server { listen 80; server_name loli.wiki www.loli.wiki loliwiki.cn www.loliwiki.cn loliwiki.cc www.loliwiki.cc loliwiki.org www.loliwiki.org; return 301 https://www.loliwiki.org$request_uri; } server { listen 443 ssl http2; server_name www.loliwiki.org; index index.php index.htm index.html; root /var/www/wiki; ssl_prefer_server_ciphers on; ssl_session_cache shared:SSL:10m; ssl_protocols TLSv1 TLSv1.1 TLSv1.2; ssl_ciphers EECDH+CHACHA20:EECDH+AES128:RSA+AES128:EECDH+AES256:RSA+AES256:EECDH+3DES:RSA+3DES:!MD5; ssl_certificate /usr/local/nginx/conf/1.crt; ssl_certificate_key /usr/local/nginx/conf/1.key; ssl_ct on; ssl_ct_static_scts /usr/local/nginx/conf/sct1; location / { try_files $uri $uri/ /index.php?$args; if (-f $request_filename) { break; } set $supercache_file ''; set $supercache_uri $request_uri; set $supercache 1; set $ihttp_host ''; if ($request_method = POST) { set $supercache 0; } set $qs 0; if ($query_string) { set $qs 1; } if ($query_string ~* "^utm_source=([^&]+)&utm_medium([^&]+)&utm_campaign=([^&]+)(&utm_content=([^&]+))?$") { set $qs 0; set $supercache_uri $document_uri; } #deactivate on high load if ($qs = 1) { set $supercache 0; } if ($http_cookie ~* "comment_author_|wordpress|wp-postpass_" ) { set $supercache 0; } if ($http_user_agent ~* '(iphone|ipod|aspen|incognito|webmate|android|dream|cupcake|froyo|blackberry9500|blackberry9520|blackberry9530|blackberry9550|blackberry 9800|webos|s8000|bada)') { set $ihttp_host '-mobile'; } if ($supercache = 0) { set $supercache_uri ''; } if ($supercache_uri ~ ^(.+)$) { set $supercache_file /var/www/html/wp-content/cache/supercache/$http_host$1/index${ihttp_host}.html; } if (-f $document_root$supercache_file) { #rewrite ^(.*)$ $supercache_file break; rewrite ^ $supercache_file last; } if (!-e $request_filename) { rewrite . /index.php last; } } rewrite /wp-admin$ $scheme://$host$uri/ permanent; location ~ /\.ht { deny all; } location ~ \.(gif|jpg|png|htm|html|css|js|ico)$ { expires 30d; } location ~ .*\.(php|php5)?$ { fastcgi_pass unix:/var/run/phpfpm.sock; fastcgi_index index.php; include fastcgi.conf; } } server { listen 80; server_name hardware.name www.hardware.name hardwareunion.com; return 301 http://www.hardwareunion.com$request_uri; } server { listen 80; server_name www.hardwareunion.com; index index.php index.htm index.html; root /var/www/html; location / { try_files $uri $uri/ /index.php?$args; if (-f $request_filename) { break; } set $supercache_file ''; set $supercache_uri $request_uri; set $supercache 1; set $ihttp_host ''; if ($request_method = POST) { set $supercache 0; } set $qs 0; if ($query_string) { set $qs 1; } if ($query_string ~* "^utm_source=([^&]+)&utm_medium([^&]+)&utm_campaign=([^&]+)(&utm_content=([^&]+))?$") { set $qs 0; set $supercache_uri $document_uri; } #deactivate on high load if ($qs = 1) { set $supercache 0; } if ($http_cookie ~* "comment_author_|wordpress|wp-postpass_" ) { set $supercache 0; } if ($http_user_agent ~* '(iphone|ipod|aspen|incognito|webmate|android|dream|cupcake|froyo|blackberry9500|blackberry9520|blackberry9530|blackberry9550|blackberry 9800|webos|s8000|bada)') { set $ihttp_host '-mobile'; } if ($supercache = 0) { set $supercache_uri ''; } if ($supercache_uri ~ ^(.+)$) { set $supercache_file /var/www/html/wp-content/cache/supercache/$http_host$1/index${ihttp_host}.html; } if (-f $document_root$supercache_file) { #rewrite ^(.*)$ $supercache_file break; rewrite ^ $supercache_file last; } if (!-e $request_filename) { rewrite . /index.php last; } } rewrite /wp-admin$ $scheme://$host$uri/ permanent; location ~ /\.ht { deny all; } location ~ \.(gif|jpg|png|htm|html|css|js|ico)$ { expires 30d; } location ~ .*\.(php|php5)?$ { fastcgi_pass unix:/var/run/phpfpm.sock; fastcgi_index index.php; include fastcgi.conf; } } } |
8
lslqtz 2016-06-21 02:04:08 +08:00
日了,配置文件突然发现写错了。。
|
9
lslqtz 2016-06-21 02:06:50 +08:00
server_name www.loliwiki.org 下的 /var/www/html 已改为 /var/www/wiki 。。
|
10
MrGba2z 2016-06-21 04:49:29 +08:00
记得重启 nginx
|
11
dixyes 2016-06-21 07:53:46 +08:00 via Android
看见辣么多 if 总感觉离段错误不远
ngx lua 大法好 |
12
ztrt 2016-06-21 08:35:48 +08:00 via Android
你的伪静态怎么这么多
location / { try_files $uri $uri/ /index.php?$args; } rewrite /wp-admin$ $scheme://$host$uri/ permanent; |
13
2232588429 OP @MrGba2z 每次都重启的啦
|
14
dixyes 2016-06-21 10:03:09 +08:00 via Android
说起来 内个 error.log 啊 access.log 啊咋说的 如果没开 要不要暂时打开看看
(总感觉讨论了半天 最后会发现一句 permission denied (报 404 |
15
2232588429 OP @dixyes 日志就没有最近的记录 T T
|
16
dixyes 2016-06-21 10:26:31 +08:00 via Android
@2232588429 日志等级不够? 或许你要开到比较 verbose 的?然后记得关
|
17
2232588429 OP @dixyes 就是看不到, rootdeng'lu 不会等级不够啊,好蛋疼!
|
18
2232588429 OP @lslqtz 我配置的是
location / { index index.html index.htm index.php; root /www/wwwroot/chinaz.com; if (-f $request_filename/index.html){ rewrite (.*) $1/index.html break; } if (-f $request_filename/index.php){ rewrite (.*) $1/index.php; } if (!-f $request_filename){ rewrite (.*) /index.php; } } 好像没问题吧,看官方文档也是这么配置的,但是打开就是不行~ |
19
lslqtz 2016-06-22 01:42:19 +08:00
@2232588429 试试看把我的照搬过去?话说, root 文件夹名是什么鬼。。
|
20
2232588429 OP @lslqtz
网站文件根目录路径,话说为啥你这个跟我差别好大.你 nginx 是咋安装的? 我是编译安装的. 我贴下我完整的 nginx.conf 配置文件. #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; location / { root /usr/abc.com/; index index.php index.html index.htm; if (-f $request_filename/index.html){ rewrite (.*) $1/index.html break; } if (-f $request_filename/index.php){ rewrite (.*) $1/index.php; } if (!-f $request_filename){ rewrite (.*) /index.php; } rewrite /wp-admin$ $scheme://$host$uri/ permanent; } #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 /usr/acb.com/; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$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 ssl; # server_name localhost; # ssl_certificate cert.pem; # ssl_certificate_key cert.key; # ssl_session_cache shared:SSL:1m; # ssl_session_timeout 5m; # ssl_ciphers HIGH:!aNULL:!MD5; # ssl_prefer_server_ciphers on; # location / { # root html; # index index.html index.htm; # } #} } |
21
lslqtz 2016-06-22 10:08:03 +08:00
@2232588429 我去掉了很多注释,附上我编译的参数吧。
nginx version: nginx/1.11.1 built with OpenSSL 1.0.2 (compatible; BoringSSL) (running with BoringSSL) TLS SNI support enabled configure arguments: --user=www --group=www --prefix=/usr/local/nginx --with-http_sub_module --with-http_stub_status_module --with-http_gzip_static_module --with-http_ssl_module --with-openssl=BoringSSL --with-http_v2_module --add-module=nginx-ct --add-module=nginx-headers-more --with-ld-opt=-lrt |
22
lslqtz 2016-06-22 10:08:49 +08:00
@2232588429 主要是 chinaz.com 吓到我了。。
|
23
2232588429 OP @lslqtz 举个栗子罢了,2333
|