How to add www?

Copy the following into a text file and save it as ".htaccess"
Place the file in your site's root directory.

Code:
Options +FollowSymLinks
 
RewriteEngine On
RewriteBase /

RewriteCond %{HTTP_HOST} !^www\.mydomain\.com$ [NC]
RewriteRule ^(.*)$ http://www.mydomain.com/$1 [R=301,L]
 
I never had a problem with any domains not automatically working as both
 
You can do this either in your apache config file or in your htaccess file if you don't have access to the apache config file.

Here's an example of what you can put in the apache config file:

Code:
<VirtualHost *:80>
    ServerName example.com
    ServerAlias www.example.com
    
    RewriteEngine on
    RewriteCond %{HTTP_HOST} !^www
    RewriteRule (.*) http://www.example.com$1 [R=301,L,QSA]
    
    [...]
</VirtualHost>

Or put this in your .htaccess file
Code:
    RewriteEngine on
    RewriteCond %{HTTP_HOST} !^www
    RewriteRule (.*) http://www.example.com$1 [R=301,L,QSA]
 
If your site is using Wordpress, just go to Settings> General > and add www to your domains on the field. that will work.
 
Hello,
I have an arcade site but url look like this http://mydomain.com but how to change it http://www.mydomain.com
I am using phpas thanks if any one help me.
:)

Make sure there's an A or CNAME record before you make the switch! To test, just open a cmd prompt or loonix shell and type:



Windows:

Code:
nslookup www.yourdomain.com

Linux:
Code:
# dig @8.8.4.4 www.yourdomain.com A
# dig @8.8.4.4 www.yourdomain.com CNAME
 
Back
Top