Welcome! Log In Create A New Profile

Advanced

rewrite don't work in a multilanguage MVC site

Fernando García Torres
October 25, 2011 12:58PM
Hi!Im trying to move from Apache to nginx (v1.1.6), but you know, rewrite newbie here... In my site when a user types http://site.com he's redirected to http://site.com/en/, and all the other URLs are internally handled by an index.php. This is my actual Apache htaccess:
RewriteEngine On
RewriteCond %{HTTP:Accept-Language} ^en [NC] RewriteRule ^$ /en/ [L,R=301]
RewriteCond %{HTTP:Accept-Language} ^es [NC] RewriteRule ^$ /es/ [L,R=301]
RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule (.*) index.php?ctr=$1 [QSA,L]
And this my translation to nginx:
location / { if (-f $request_filename) { expires 30d; break; }
if ($http_accept_language ~* "^es") { rewrite ^/$ /es/ permanent; break; }
if ($http_accept_language ~* "^en") { rewrite ^/$ /en/ permanent; break; }
if (!-e $request_filename) { rewrite (.*) /index.php?ctr=$1 last; } } location ~ \.php$ { fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; ...
With this, when I type http://site.com I'm being redirected to http://site.com/en/, great, but I get a 404 error, and in the error.log I have this line:
"/bla/bla/html/en/index.php" is not found
So, why is not nginx looking for the URI /index.php?ctr=/en/? _______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Subject Author Posted

rewrite don't work in a multilanguage MVC site

Fernando García Torres October 25, 2011 12:58PM

Re: rewrite don't work in a multilanguage MVC site

António P. P. Almeida October 25, 2011 01:16PM

RE: rewrite don't work in a multilanguage MVC site

Fernando García Torres October 25, 2011 02:18PM

Re: rewrite don't work in a multilanguage MVC site

António P. P. Almeida October 25, 2011 02:34PM

RE: rewrite don't work in a multilanguage MVC site

Fernando García Torres October 25, 2011 03:02PM

Re: rewrite don't work in a multilanguage MVC site

Francis Daly October 25, 2011 04:24PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 148
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready