nginx server redirect

Edho P Arief edhoprima at gmail.com
Sun Jun 21 09:19:01 MSD 2009


On Sun, Jun 21, 2009 at 12:04 PM, Edho P Arief<edhoprima at gmail.com> wrote:
> On Sun, Jun 21, 2009 at 4:17 AM, Kevin
> Castiglione<kevincastiglione at gmail.com> wrote:
>> On Sat, Jun 20, 2009 at 2:15 PM, Kevin Castiglione
>> <kevincastiglione at gmail.com> wrote:
>>>
>>> On Fri, Jun 19, 2009 at 11:17 PM, Edho P Arief <edhoprima at gmail.com>
>>> wrote:
>>>>
>>>> On Sat, Jun 20, 2009 at 12:44 PM, Kevin
>>>> Castiglione<kevincastiglione at gmail.com> wrote:
>>>> > hi
>>>> > if any one goes to
>>>> > XXX.aaa.com/bbb
>>>> >
>>>> > i want to do a permanent redirect to
>>>> > aaa.com/bbb
>>>> >
>>>> >
>>>> > any suggestions on how to do this?
>>>> > thank you
>>>> >
>>>>
>>>> server {
>>>>  listen 80;
>>>>  server_name *.aaa.com;
>>>>  rewrite ^.* http://aaa.com$uri;
>>>> }
>>>
>>> edho:
>>> thanks for this. im going to be handling multiple domains, so is it
>>> possible to do this rewrite without hardcoding?
>>>
>>>   rewrite ^.* http://aaa.com$uri;
>>>
>>> for ex somthing like
>>>   rewrite ^.* http://$maindomain$uri;
>>
>> also this rewrite rule gives Redirect Loop error on all browsers.
>> thank you
>>
>
> I forgot to escape the dot.
>
> did you mean:
> NNN.somedomain.tld => somedomain.tld
> for any somedomain.tld?
>

here it is
        server {
                listen 80;
                server_name ~(.*)\.([^\.]*)\.([^\.]*)$;
                set $domain $2.$3;
                rewrite ^.* http://$domain$request_uri permanent;
        }

-- 
O< ascii ribbon campaign - stop html mail - www.asciiribbon.org





More information about the nginx mailing list