Hi all

I've searched everywhere on the internet including Daniweb for this answer but I can't find one.

I don't want to break the rules, so I've changed the real domain name to domain.co.uk

I manage a website www.domain.co.uk where the owner requires a subdomain called

He then needs the quotes subdomain to reroute to a third party site.

So I've logged into the cPanel, set-up an A DNS record (called quotes) and great, it reroutes.

But I've discovered that if I enter it doesn't reroute through to the third party site. Instead, I receive:
in Google Chrome, the "Oops! Google Chrome could not find " error page.
In Opera it gives a "Network Error" error page.
In Firefox a "Server Not Found" error page.

So now I need to have the www version of the sub-domain redirect to the non-www version; i.e. redirects to

I've tried several different .htaccess solutions, which I won't bore you with here; suffice to say that none of them have worked.

Please can anyone help me to resolve this?

Thanks

Rob

Dani AI

Generated

Short answer: nothing is listening for the hostname "www.quotes.domain.co.uk" in DNS, so the browser never reaches a webserver. The "www" prefix is just another label — it does not get created automatically when you add quotes.domain.co.uk. That is why sees the NXDOMAIN/“could not find” error, and why any .htaccess or rewrite rules (like the idea from ) cannot take effect until DNS resolves the name to an IP.

Steps to confirm:

dig +short quotes.domain.co.uk
dig +short www.quotes.domain.co.uk
# or
nslookup www.quotes.domain.co.uk

If the second command returns nothing or NXDOMAIN, DNS is the problem.

How to fix (recommended, in order):

  • In your DNS control panel / cPanel Zone Editor add either
    • a CNAME for www.quotes pointing to quotes.domain.co.uk.
      or
    • an A record for www.quotes with the same IP used by quotes.domain.co.uk.
      Example zone-entry styles:
      www.quotes    IN CNAME   quotes.domain.co.uk.
      # or
      www.quotes    IN A       203.0.113.45

      (Use your actual IP; the above IP is an example.)

After DNS changes:

  • Allow TTL to propagate (usually minutes to a few hours). Flush local DNS cache (e.g. ipconfig /flushdns on Windows) and re-run the dig/nslookup checks.
  • If the site is proxied to a third party, confirm the third party accepts requests for the www host. If you control the webserver, add the hostname (ServerAlias or equivalent) and then implement a 301 redirect from www.quotes.domain.co.uk to quotes.domain.co.uk for SEO. Finally, remember HTTPS: a cert must cover the www name or users will get certificate errors.

Recommended Answers

All 2 Replies

Member Avatar for Member #120589

do you have cPanel? If so, there should be a redirect option which should give you what you need.

else:

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

Ensure that you've got RewriteEngine On If you have access to httpd.conf, you could do this:

<VirtualHost *>
  ServerName www.domain.co.uk
  Redirect 301 / http://domain.co.uk/
</VirtualHost>

However, I haven't tried it. I'm no expert on .htaccess, so take my advice with a pinch of salt. Anybody else?

Hi ardav - thanks for your advice. I had a sudden realisation though that actually both the and the www.domain.com are subdomains...so the doesn't actually exist!
But thank you so much for your time in answering this. If I am wrong on this though, it would be great for someone else, or yourself, to jump in and correct me. Or you can leave me in blissful ignorance!
Cheers

Rob

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.