2

我有一个 Joomla 网站,我想将它从 Apache 服务器转移到 Nginx。我的网站有 3 种语言,所有 URL 都以/en/ua或开头/ru。SEF URL 已启用并在 Apache 上完美运行。

网站文件夹有 .htaccess 文件,其中(据我了解)最重要的指令是:

RewriteEngine On
RewriteCond %{HTTP_HOST} ^www.domain.com$ [NC]
RewriteRule ^(.*)$ http://domain.com/$1 [R=301,L]
DirectoryIndex index.php index.html
Options +FollowSymLinks
Options -Indexes
<IfModule mod_rewrite.c>    
RewriteEngine On 
RewriteBase /    
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^(.+) - [PT,L]
RewriteRule ^(.*) index.php
RewriteCond %{HTTP:Authorization}  !^$
RewriteRule .* - [E=REMOTE_USER:%{HTTP:Authorization}]
</IfModule>

我使用了http://winginx.com/en/htaccess转换器,并将其结果放入/etc/nginx/site-available/domain.com文件中:

index index.php index.html; 
autoindex off; 
location / { 
    if ($http_host ~* "^www.domain.com$")       { 
        rewrite ^(.*)$ http://domain.com/$1 redirect;
    } 
    if (-e $request_filename) {
        rewrite ^/(.*) /index.php;
    }
}

然后我读了一本手册(https://docs.joomla.org/Enabling_Search_Engine_Friendly_%28SEF%29_URLs#Nginx),但也try_files $uri $uri/ /index.php?q=$request_uri;没有expires 1d; try_files $uri $uri/ /index.php?$args;帮助我。

如果我尝试使用上一段中的指令在浏览器中打开网站,则会出现 504(网关超时)错误;error.log 包含下一个错误:

*1 upstream timed out (110: Connection timed out) while reading response header from upstream, client: 176.***.**.***, server: domain.com, request: "GET /en/ HTTP/1.1", upstream: "fastcgi://unix:/var/run/php5-fpm.sock:", host: "domain.com"

如果我不使用它而只使用从 .htaccess 转换的指令,那么我会收到 500(内部服务器)错误,并且 error.log 包含下一件事:

*1 rewrite or internal redirection cycle while internally redirecting to "/ru/", client: 176.***.**.***, server: domain.com, request: "GET /ru/ HTTP/1.1", host: "domain.com"

我一整天都在尝试谷歌解决方案,但我认为没有专家的帮助我无法处理这个问题:(

同样在 Joomla 控制面板上,我发现“SEF URL 在 Apache 和 IIS7 上正常工作”,并且没有关于 Nginx 的信息。虽然在 docs.joomla.org 有一个解决方案,但它不起作用或者我做错了 =/

请。帮助!

4

0 回答 0