【发布时间】:2019-09-13 16:51:41
【问题描述】:
我一直使用 Apache 作为我的 Web 服务器,但我现在因为其他原因不得不使用 NGINX。它现在在 AWS Linux AMI 上运行。 这是我第一次玩,我设法让一个空白配置工作,但是当我添加我从 .htaccess 转换的规则时,我不断让网站进入重定向。不确定它是否是我的配置。另外,我不确定你是否需要一个单独的 443?
server {
listen 80;
server_name sitename.co.uk www.sitename.co.uk;
root /var/www/html/Project;
location / {
try_files $uri $uri/ /index.php?$args;
if (!-e $request_filename){
rewrite ^/([^\.]+)$ /$1.php break;
}
if ($http_host ~* "^sitename\.co.uk"){
rewrite ^(.*)$ https://sitename.co.uk/$1 redirect;
}
if (!-e $request_filename){
rewrite ^(.*)$ /index.php break;
}
if (!-e $request_filename){
rewrite ^(.*)$ /index.php break;
}
}
access_log /var/log/nginx/sitename.access.log;
error_log /var/log/nginx/sitename.co.uk.error.log;
}
任何帮助都会很棒。
【问题讨论】:
-
我怀疑这是因为第二个
if块 - 重写和重定向。这看起来像是用于从 http 重定向到 https,并且在该上下文中不起作用。
标签: amazon-web-services web-services nginx nginx-config