Rewrite or internal redirection cycle?

António P. P. Almeida appa at perusio.net
Wed Jun 15 18:45:30 MSD 2011


On 15 Jun 2011 15h33 WEST, appa at perusio.net wrote:

> On 15 Jun 2011 14h11 WEST, nginx-forum at nginx.us wrote:
>
>> I get the same problem with TECK The difference is my homepage is
>> work well, but when I tried to click a link on my homepage, it's
>> get me 500 Internal Server Error.
>>
>> Here my configuration:
>
> Your configuration suffers from a lot of mod_rewrite influenced
> thinking. As Igor calls it, it's a Yoda style of configuration.
>
>
> This makes no sense. You're doing a capture that you don't use and
> you seem to be rewriting to the same URI.
>
>> if (-f $document_root/maintenance.html) {
>> rewrite  ^(.*)$  /maintenance.html last;
>> break;
>> }
>
> location = /maintenance.html { }
>
> location / {
> try_files $uri $uri/ /index.php?q=$uri&$args;
> }
>
> location /administrator/ {
> rewrite ^ https://www.domain.com$request_uri? permanent;
> }
>
> location ~* com_login {
> rewrite ^ https://www.domain.com$request_uri? permanent 
>
> }
>

This can be made simpler I believe. Just 

location /en/(.*)$ {
  index index.php;
  try_files $uri $uri/ /en/index.php?$1; 
}

should do the trick. Try it.

Also you'll need to create another location for = /en/index.php.

location = /en/index.php {
   fastcgi_pass 127.0.0.1:9000;                 
   fastcgi_index index.php;                     
   fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;  
   include /usr/local/nginx/conf/fastcgi_params;
}

--- appa





More information about the nginx mailing list