Forum: NGINX Rewrite Rules from apache

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.
Ab25f33ef3326f0ca28755116e98416c?d=identicon&s=25 Daniel (Guest)
on 2016-07-07 18:50
(Received via mailing list)
Hi Everyone,

i try to convert some rules from apache htaccess to nginx.

This is my htaccess Rule:

 RewriteCond %{DOCUMENT_ROOT}/$3 -f
 RewriteRule ^(.*?)/(.*?)/(.*)$ /$3

I tried these options but it seems not working:

if (-f $document_root/$3){
  set $rule_0 1$rule_0;
}
if ($rule_0 = "1"){
  rewrite ^/(.*?)/(.*?)/(.*)$ /$3;
}

Anyone have a good idea?

Cheers

Daniel
187c77fbd13c54f990b63d0df95a6cb1?d=identicon&s=25 unknown (Guest)
on 2016-07-07 19:20
(Received via mailing list)
July 7 2016 10:19 PM, "Daniel" <daniel@linux-nerd.de> wrote:
>
>
> Daniel
>
> _______________________________________________
> nginx mailing list
> nginx@nginx.org
> http://mailman.nginx.org/mailman/listinfo/nginx


how about

location ^/(.*?)/(.*?)/(.*)/(.*)$ {
    try_files /$3 $uri =404;
}
Ab25f33ef3326f0ca28755116e98416c?d=identicon&s=25 Daniel (Guest)
on 2016-07-07 19:26
(Received via mailing list)
Same issue.

All images CSS Files and so on are not loaded :(
36a8284995fa0fb82e6aa2bede32adac?d=identicon&s=25 Francis Daly (Guest)
on 2016-07-08 09:39
(Received via mailing list)
On Thu, Jul 07, 2016 at 06:49:21PM +0200, Daniel wrote:

Hi there,

> This is my htaccess Rule:
>
>  RewriteCond %{DOCUMENT_ROOT}/$3 -f
>  RewriteRule ^(.*?)/(.*?)/(.*)$ /$3

I suspect that some previous part of the htaccess file has a regex which
sets $3. What is that?

Or, alternatively:

What http request do you make?

What response do you want? As in, what file on your filesystem do you
want nginx to return, for this request?

  f
--
Francis Daly        francis@daoine.org
This topic is locked and can not be replied to.