Forum: NGINX need help with rewrite

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Glen L. (Guest)
on 2008-12-11 06:12
(Received via mailing list)
Hi



Can someone help me in translating this rewrite into nginx?



    RewriteCond %{REQUEST_URI} ^(/component/option,com) [NC,OR]
##optional - see notes##

    RewriteCond %{REQUEST_URI} (/|\.htm|\.php|\.html|/[^.]*)$  [NC]

    RewriteCond %{REQUEST_FILENAME} !-f

    RewriteCond %{REQUEST_FILENAME} !-d

    RewriteRule (.*) index.php

    RewriteCond %{QUERY_STRING} mosConfig_[a-zA-Z_]{1,21}(=|\%3D) [OR]

    RewriteCond %{QUERY_STRING} base64_encode.*\(.*\) [OR]

    RewriteCond %{QUERY_STRING} (\<|%3C).*script.*(\>|%3E) [NC,OR]

    RewriteCond %{QUERY_STRING} GLOBALS(=|\[|\%[0-9A-Z]{0,2}) [OR]

    RewriteCond %{QUERY_STRING} _REQUEST(=|\[|\%[0-9A-Z]{0,2})

    RewriteRule ^(.*)$ index.php [F,L]



Appreciate your help
Igor S. (Guest)
on 2008-12-11 09:05
(Received via mailing list)
On Thu, Dec 11, 2008 at 11:03:23AM +0700, Glen L. wrote:

>
>     RewriteCond %{REQUEST_FILENAME} !-d
>
>     RewriteRule (.*) index.php

As I understand these are Joomla rewrite rules. If you have no any
dot-files,
as .htaccess, then the regex part "/[^.]*)$" means effectively anything,
i.e.
"location /".

The RIGHT nginx configuration is

    root  /path/to/files;

    location / {
         log_not_found  off;
         error_page  404 = @joomla;
    }

    location @joomla {
         fastcgi_pass   ...;
         fastcgi_param  SCRIPT_FILENAME  /path/to/index.php;
         ... other fastcgi_params

    }

If you have also other php files, then add

    location ~ \.php$ {
         fastcgi_pass   ...;
         fastcgi_param  SCRIPT_FILENAME  /path/to/$fastcgi_script_name;
         ... other fastcgi_params
    }

If you have static dot-files, then add:

    location ~ /\. { }

>     RewriteRule ^(.*)$ index.php [F,L]
I have no idea WHY Joomla developers think that Joomla parameters
validation should be placed on web server side. Please, send them
feedback,
that these rules should be implemented inside Joomla: this is not web
server job.
Igor S. (Guest)
on 2008-12-11 09:15
(Received via mailing list)
On Thu, Dec 11, 2008 at 09:51:10AM +0300, Igor S. wrote:

> >
> >     RewriteCond %{REQUEST_FILENAME} !-f
> >
> >     RewriteCond %{REQUEST_FILENAME} !-d
> >
> >     RewriteRule (.*) index.php
>
> As I understand these are Joomla rewrite rules. If you have no any dot-files,
> as .htaccess, then the regex part "/[^.]*)$" means effectively anything, i.e.
> "location /".

Sorry, "/[^.]*)$" means files without dots at all. So the configuration
is
the same, expect, thay you should handle images in some static location:

      location ~ \.(gif|jpg|png)$ { }
Glen L. (Guest)
on 2008-12-11 09:17
(Received via mailing list)
Thank you so much Igor.. It's works very nice :)


Regards,

Glen L.
This topic is locked and can not be replied to.