Redirecting subdomain to www gives page not found error

domain-name-systemhostingsubdomain

On my vps plesk server I have created one domain mydomain.com and for that domain I have created subdomain as subdomain.mydomain.com but if i redirect this subdomain to www.subdomain.mydomain.com using .htaccess file I gets an error as page could not be found . what must be the problem.

This is my .htaccess code to redirect

RewriteEngine On

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

This is what my A host looks like

Host         Points To       TTL
@           166.xx.xx.yyy   600 seconds
admin       166.xx.xx.yyy   600 seconds
subdomain   166.xx.xx.yyy   1 Hour

Best Answer

You are probably missing a DNS entry for your www.subdomain.mydomain.com subdomain.

Add another A entry, for your "www" subdomain to point to your servers address, and it should work (if the virtualhost or alias is set up on the server correctly).

Related Topic