2

I have a Joomla website which I want to move from Apache server to Nginx. My website have 3 languages and all URLs begins with /en, /ua or /ru. SEF URLs are enabled and work perfectly at Apache.

Website folder have .htaccess file, where (as far as I understand) the most important directives are:

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>

I used http://winginx.com/en/htaccess converter, and placed its result into /etc/nginx/site-available/domain.com file:

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;
    }
}

Then I've read a manual (https://docs.joomla.org/Enabling_Search_Engine_Friendly_%28SEF%29_URLs#Nginx), but nor try_files $uri $uri/ /index.php?q=$request_uri; nor expires 1d; try_files $uri $uri/ /index.php?$args; doesn't help me.

If I try to open website in my browser using directives from previous paragraph, I've got 504 (gateway timeout) error; error.log contains next error:

*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"

If I don't use this and just use my directives which was converted from .htaccess, then I've got 500 (internal server) error and error.log contains next thing:

*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"

I try to google solutions a whole day, but I think I can't handle this without help of specialist :(

Also at Joomla control panel I've found that "SEF URLs work correctly at Apache and IIS7", and there is no info about Nginx. Though at docs.joomla.org there is a solution, but it doesn't work or I do something wrong =/

Please. Help!

Alukret
  • 21
  • 5

0 Answers0