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
  • do you have the DNS entry for the www.subdomain.mydomain.com set up? – mulaz Feb 20 '14 at 17:19
  • I have dns entry for the subdomain.mydomain.com it works fine . Do i need to create dns entry sepearately for www redirect? – minu Feb 20 '14 at 17:20
  • yes, you need another one for www. – mulaz Feb 20 '14 at 17:23

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).

| improve this answer | |
  • Currently this is wat my A host looks like @ 166.xx.xx.xx – minu Feb 20 '14 at 17:29
  • you need A record for subdomain.mydomain.com to point to 166.x.x.x, and another A record for www.subdomain.mydomain.com to point to the same IP address (if both pages are served by the same server) – mulaz Feb 20 '14 at 17:32
  • i have edited my question with the A host file . – minu Feb 20 '14 at 17:34
  • where is the www.subdomain ? you need one for that too. – mulaz Feb 20 '14 at 17:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.