redirecting non www to www.

Jonathan Dance jd at wuputah.com
Mon Jan 15 04:53:45 MSK 2007


You would use a separate server directive for this:

server {
  server_name example.com;
  listen 80;
  location / {
    rewrite ^(.*) http://www.example.com$1 permanent;
  }
}

Cheers,
JD

On 1/14/07, ianevans at digitalhit.com <ianevans at digitalhit.com> wrote:
> Just trying to clean things up for Google's duplicate issues...this might
> be a basic example to toss in the rewrite module part of the wiki for
> people who suck at regex's like me. <g>
>
> So a) who would you redirect a example.com request to www.example.com and
> b) where would it go in the order of the locations:
>
> location / {
> ...
> }
>
> location ~* ^.+\.(jpg|jpeg|gif|png|ico|css|js|mov)$ {
> ...
> }
>
> Thanks.
>
> --
> Ian Evans
>
>
>





More information about the nginx mailing list