Jump to content

How to Redirect non-www to www URLs


Recommended Posts

  • 3 years later...
  • 4 months later...
  • 3 weeks later...
  • 2 weeks later...

Redirecting non-www to www URLs is a common practice used to ensure that all traffic to your website is directed to a single domain. Here are the steps to redirect non-www to www URLs:

Determine your web server type: The steps to redirect non-www to www URLs will depend on the type of web server you are using. The two most common types are Apache and NGINX.

Create a redirect rule: Once you know your web server type, you can create a redirect rule that will redirect all non-www traffic to the www version of your domain. Here are the redirect rules for both Apache and NGINX:

Apache:
Add the following code to your .htaccess file:

RewriteEngine On
RewriteCond %{HTTP_HOST} !^www. [NC]
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [L,R=301]

NGINX:
Add the following code to your server block:

server {
listen 80;
server_name example.com;
return 301 $scheme://www.example.com$request_uri;
}

Test the redirect: After creating the redirect rule, test it to make sure that it is working properly. You can do this by typing in the non-www version of your domain into a browser and verifying that it redirects to the www version.
Once you have completed these steps, all non-www traffic to your website should be automatically redirected to the www version of your domain. This can help ensure that all of your website traffic is directed to a single domain and can help with SEO and website analytics tracking.

https://crecentech.com/

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated