Domain doesn't work without `www`
All you need is to add the following code to your root .htaccess
file:
RewriteEngine on
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
With the current version of apache, you need to do the following, which has changed compared to the previous versions:
cd /etc/apache2/sites-enabled
Now find the config file for your domain and edit it (the first three lines after <VirtualHost *:80>
is what we need here):
<VirtualHost *:80>
ServerName www.yourdomain.com
ServerAlias yourdomain.com *.yourdomain.com
ServerAdmin webmaster@localhost
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
</VirtualHost>
And now after saving changes to the file, you should reload Apache we server configuration with:
service apache2 reload
and it'll work!
P.S. You may also want not to add *.yourdomain.com
to the end of your ServerAlias
line.
to solve this issue
suppose you want
mysubdomain.domain1.com
goto your dns records settings in your web panel ( cpanel , vestapanel etc ) of
domain1.com
add there new
A record
withip
of yourdomain1.com
and fill record/hostname field with@
// @ mean no www if you want www too then add another newA record
and replace@
with wwwsave it
wait for dns changes to take place maybe take few hours