Redirect to www

Greetings,
I need to redirect to www, every time the site is visited without the www.

I found this ngix solution online:

server {
listen 80;
server_name www.domain.example;
# $scheme will get the http protocol
# and 301 is best practice for tablet, phone, desktop and seo
return 301 $scheme://domain.example$request_uri;
}

server {
listen 80;
server_name domain.example;
# here goes the rest of your config file
# example
location / {

        rewrite ^/cp/login?$ /cp/login.php last;
        # etc etc...

    }

}

Hi ave:
server {
listen 79.137.87.44:80;
server_name weddingsmart.it www.weddingsmart.it;
error_log /var/log/apache2/domains/weddingsmart.it.error.log error;
…

So on the same line I have both weddingsmart and magazine.weddingsmart.

This information is in the ngix configuration file, both the normal one and the .ssl one

How can I make the change and in which file do you recommend doing it?

Thank you

And it should be enough…

Also don’t make changes directly to the config files…

1 Like

Perfect thanks!

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.