我在子文件夹中有一个带有wordpress的网站(/ tips),我无法在nginx上正常使用它。在Chrome中,它或多或少都有效,但在Edge上它根本不起作用。
它使用php5在Ubuntu 16.04上。
我试图使用wordpress.org上的文档(location = / tips),但它只是404.因此,我必须使用重写,因为您将在下面看到。
这是现有的nginx配置:
server {
listen 443 ssl;
server_name www.domain.co.uk;
add_header Strict-Transport-Security "max-age=31536000; includeSubDomains";
root /var/www/domain.co.uk;
index index.php;
ssl on;
ssl_certificate /etc/nginx/ssl/ssl-bundle.crt;
ssl_certificate_key /etc/nginx/ssl/www_domain_co_uk.key;
ssl_dhparam /etc/nginx/ssl/dhparam.pem;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers "EECDH+ECDSA+AESGCM EECDH+aRSA+AESGCM EECDH+ECDSA+SHA384 EECDH+ECDSA+SHA256 EECDH+aRSA+SHA384 EECDH+aRSA+SHA256 EECDH+aRSA+RC4 EECDH EDH+aRSA RC4 !aNULL !eNULL !LOW !3DES !MD5 !EXP !PSK !SRP !DSS +RC4 RC4";
ssl_prefer_server_ciphers on;
location / {
try_files $uri $uri.html $uri/ =404;
}
location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/run/php/php5.6-fpm.sock;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_index index.php;
include fastcgi_params;
}
rewrite ^/tips/(.*) /tips/index.php?$args;
if (!-f $request_filename) {
set $rule_3 1$rule_3;
}
if (!-d $request_filename) {
set $rule_3 2$rule_3;
}
if ($uri !~ ".*.(ico|gif|jpg|jpeg|png|js|css)") {
set $rule_3 3$rule_3;
}
if ($rule_3 = "321") {
rewrite ^/([^?]*) /index.php?_route_=$1 last;
}
location ~* \.(jpg|jpeg|gif|png|css|js|ico|xml)$ {
access_log off;
log_not_found off;
expires 30d;
}
}
答案 0 :(得分:1)
您是否为每个与现有文件匹配的电话返回404?
location / {
try_files $uri $uri.html $uri/ =404;
}
答案 1 :(得分:1)
看起来每个进入/ tips的页面都会被重定向回/ tips ...
确实看起来像无限重定向
rewrite ^/tips/(.*) /tips/index.php?$args;
一个快速谷歌建议类似的东西,但我再也不能100%肯定你想要实现的目标
location /tips/ {
try_files $uri /index.php$args =404;
}
答案 2 :(得分:0)
发现问题所在 - 它与核心站点重写(对于opencart)存在冲突。修正了以下内容:
location / {
try_files $uri $uri/ @opencart;
}
location @opencart {
rewrite ^/(.+)$ /index.php?_route_=$1 last;
}
location /tips/ {
try_files $uri $uri/ /tips/index.php?$args;
}