我正在尝试为我的nginx配置添加新位置。我将ngix设置为this webpage。现在我认为配置文件中对我来说最重要的一行就是这一行:
include /usr/local/etc/nginx/sites-enabled/*;
因此它包含sites-enabled
文件夹中的所有配置文件。现在我有一个默认配置文件和一个default-ssl配置文件。
server {
listen 443;
server_name localhost;
root /var/www/;
access_log /usr/local/etc/nginx/logs/default-ssl.access.log main;
ssl on;
ssl_certificate ssl/localhost.crt;
ssl_certificate_key ssl/localhost.key;
ssl_session_timeout 5m;
ssl_protocols SSLv2 SSLv3 TLSv1;
ssl_ciphers HIGH:!aNULL:!MD5;
ssl_prefer_server_ciphers on;
location / {
include /usr/local/etc/nginx/conf.d/php-fpm;
}
location = /info {
allow 127.0.0.1;
deny all;
rewrite (.*) /.info.php;
}
error_page 404 /404.html;
error_page 403 /403.html;
}
现在我想添加一个新的子文件夹redux
。我尝试了这个配置部分:
location = /redux {
rewrite (.*) /redux/index.php;
}
但它根本不起作用,我只收到此错误消息:
015/09/15 10:10:41 [error] 844#0: *7 "/var/www/redux/user/login/index.html" is not found (2: No such file or directory), client: 127.0.0.1, server: localhost, request: "POST /redux/user/login/ HTTP/1.1", host: "localhost", referrer: "https://localhost/redux/"
但我的期望是,/ user / login部分被赋予redux / index.php下的index.php作为参数。
我需要改变什么?
我的.htaccess看起来像这样
Options +FollowSymLinks
RewriteEngine On
RewriteRule ^(Templates|cache|uploads)($|/) - [L]
RewriteRule ^(.*)$ index.php [NC,L]
答案 0 :(得分:0)
我的最终解决方案看起来像这样:
location /redux/ {
try_files $uri $uri/ /redux/index.php?$args;
include /usr/local/etc/nginx/conf.d/php-fpm;
}