Forum: NGINX How to rewrite this correctly?

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 2009-01-29 05:00
(Received via mailing list)
Hello!



I have a directory images/stories (using joomla)

I need to rewrite this into my other subdomains



Here's what I already set and works. But not as I expected

        location /images/stories {

          rewrite ^(.*)$ http://static.mydomain.com$1 redirect;

        }



When it's accessed by users, it will redirect me to
http://static.mydomain.com/images/stories



How can I rewrite it into http://static.mydomain.com/files/images ?



Thank's a lot before
Ask Bjørn Hansen (Guest)
on 2009-01-29 05:34
(Received via mailing list)
On Jan 28, 2009, at 6:52 PM, Glen L. wrote:

> Here’s what I already set and works. But not as I expected
>         location /images/stories {
>           rewrite ^(.*)$ http://static.mydomain.com$1 redirect;
>         }
>
> When it’s accessed by users, it will redirect me to 
http://static.mydomain.com/images/stories
>
> How can I rewrite it into http://static.mydomain.com/files/images ?


Here are a few variations:

rewrite ^/images/(.*)$ http://static.mydomain.com/files/images/$1
redirect;
rewrite ^/(.*)$ http://static.mydomain.com/files/$1 redirect;
Glen L. (Guest)
on 2009-01-29 05:45
(Received via mailing list)
-----Original Message-----
From: removed_email_address@domain.invalid 
[mailto:removed_email_address@domain.invalid] On Behalf Of
Ask
Bjørn Hansen
Sent: 29 Januari 2009 10:25
To: removed_email_address@domain.invalid
Subject: Re: How to rewrite this correctly?

>
>On Jan 28, 2009, at 6:52 PM, Glen L. wrote:
>
>> Here’s what I already set and works. But not as I expected
>>         location /images/stories {
>>           rewrite ^(.*)$ http://static.mydomain.com$1 redirect;
>>         }
>>
>> When it’s accessed by users, it will redirect me to
http://static.mydomain.com/images/stories
>>
>> How can I rewrite it into http://static.mydomain.com/files/images ?


>Here are a few variations:
>
>rewrite ^/images/(.*)$ http://static.mydomain.com/files/images/$1
>redirect;
>rewrite ^/(.*)$ http://static.mydomain.com/files/$1 redirect;

Can you please explain me the details about it?
rewrite ^/images/(.*)$ http://static.mydomain.com/files/images/$1
redirect;
Is that correct if i use
rewrite ^/images/stories/(.*)$
http://static.mydomain.com/files/images/$1
redirect; ?

How about rewrite ^/(.*)$ http://static.mydomain.com/files/$1 redirect;
?
This topic is locked and can not be replied to.