Welcome! Log In Create A New Profile

Advanced

Re: Moving Joomla from subdir to root -> rewrite / redirect problem

Johannes Rohr
December 22, 2017 02:00PM
Am 18.12.2017 um 20:36 schrieb Francis Daly:
> On Fri, Dec 15, 2017 at 03:25:20PM +0100, Johannes Rohr wrote:
>
> Hi there,
>
> I do not know joomla; and I do not have a direct answer for you.
>
> But some parts of your question seem unclear to me.
>
> Perhaps they are also unclear to someone who otherwise could give an answer.
>
> If you can clarify them, maybe that other person can help.

I will try my best.
>> in order to have prettier URLs I have decided to move my joomla from
>> /web/ to /, but I want old URLs to transparently redirect.
> When you say "transparently redirect", can you give an example of what
> you mean?
>
> As in: when I request /web/something, should I get a http redirect so
> that I next request /something; or should I get something else?
Yes, sure, that's precisely what I want to achive

>> location /web {
>>   try_files $uri $uri/ /index.php?$args;
>>  }
>>
>> but this obviously did not work as the arguments passed to index.php
>> still contain the /web/   part  , which would have to go.
> Without knowing joomla... why is this obvious? Why would arguments to
> index.php include /web/?
Because that is the subdir where it is currently installed. (which I
want to change)

>
> And: what, specifically, did you do on the joomla side, to move it from
> /web/ to /?

Nothing really besides moving the files, as Joomal adjusts all the
variables on the fly. And Joomla is perfectly happy with that, only the
redirect does not work

>> So I tried instead:
>>
>> location / {
>>     rewrite ^/web/(.*)$ /$1;
>>   try_files $uri $uri/ /index.php?$args;
>> }
>>
>> thinking that the first line would modify the URI, taking away the /web/
>> part so that in the next line the changed uri would be fed to the
>> try_files command.
> Yes. It does not do anything about "arguments to index.php", though,
> which was your reported problem with the first attempt.
>
> (I'd probably include "break" on the rewrite line; but it might depend
> on what the rest of your config says.)
Why? Doesn't "break" mean that processing is ended after the current
line? What I want is that the re-written url is then fed to the
try_files directive below, which calls joomla's index.php

>> But this only resulted in 404s.
> Can you show one request that you make, and describe how you would like
> it to be handled?


So now I am trying this:

     # Support Clean (aka Search Engine Friendly) URLs
        location / {
if ($request_uri ~* "^/web/(.*/)$") {
        return 301 $1;
    }

                try_files $uri $uri/ /index.php?$args;
        }


I kind of hoped this would would catch each request that contails /web/
and rewrite it into something with /web/ stripped and then feed it to
try_files directive below.

But in the nginx log I see:

2017/12/22 19:43:55 [error] 21149#21149: *19151503 FastCGI sent in
stderr: "Unable to open primary script:
/var/www/chrooted/jrweb/htdocs/www.infoe.de/web/index.php (No such file
or directory)" while reading response header from upstream, client:
65.19.138.35, server: www.infoe.de, request: "GET
/web/index.php?format=feed&type=rss HTTP/1.1", upstream:
"fastcgi://unix:/run/php/php7.0-fpm.sock:", host: "www.infoe.de"

So, somehow, the rewrite is not happening, nginx still looks for
/web/index.php instead of /index.php

Of course, the return the browser gets is a 404

I find this topic so confusing (and reading the official nginx docs does
not make the confusion go away), would be grateful if anyone could
enlighten me!

Cheers,

Johannes


>
> Cheers,
>
> f


_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Subject Author Posted

Moving Joomla from subdir to root -> rewrite / redirect problem

Johannes Rohr December 15, 2017 09:28AM

Re: Moving Joomla from subdir to root -> rewrite / redirect problem

Francis Daly December 18, 2017 02:38PM

Re: Moving Joomla from subdir to root -> rewrite / redirect problem

Johannes Rohr December 22, 2017 02:00PM

Re: Moving Joomla from subdir to root -> rewrite / redirect problem

Francis Daly December 23, 2017 07:30AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 203
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