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

Francis Daly francis at daoine.org
Mon Dec 18 19:36:52 UTC 2017


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.

> 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?

> 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/?

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

> 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.)

> But this only resulted in 404s.

Can you show one request that you make, and describe how you would like
it to be handled?

Cheers,

	f
-- 
Francis Daly        francis at daoine.org


More information about the nginx mailing list