Knowledgebase

Portal Home > Knowledgebase > Articles Database > Redirect example.com to www.example.com


Redirect example.com to www.example.com




Posted by Think Tank Networks, 08-01-2009, 11:23 PM
I have multiple domains on my web server. One of my domains does not display its website when using example.com in the location bar. Eg. example.com redirects to site2.com but www.example.com displays properly. I tried adding to the htaccess file: It doesn't work. The redirect does not occur. Any idea how do i fix this?

Posted by 111111z, 08-01-2009, 11:39 PM
Options +FollowSymlinks RewriteEngine on RewriteBase / RewriteCond %{HTTP_HOST} !^example.com$ [NC] RewriteRule ^(.*)$ http://example.com/$1 [L,R=301] in this code I use it redirects www.example.com to example.com maybe that would help....but I think you want to reverse what I do.

Posted by Think Tank Networks, 08-01-2009, 11:52 PM
That's just a small variation of what i tried (redirect is different). I tried it anyways and it didnt work either.

Posted by supportexpertz, 08-02-2009, 12:01 AM
Can you provide the results of following commands dig example.com dig www.example.com

Posted by Think Tank Networks, 08-02-2009, 12:44 AM
Here's my zone file:

Posted by 111111z, 08-02-2009, 01:08 AM
If my example did not work for you maybe your apache is not enabled for htaccess in apache config file for that domain. . maybe you need the AccessFileName .htaccess in the apache config file

Posted by supportexpertz, 08-02-2009, 01:23 AM
The domain should point / resolve to your server properly. From the "dig" result its shows that the domain is reaching the nameservers but for some reason its not resolving completely. Confirm whether you have made any recent changes at your domain name registrar. Also the zone file entry should complete with a dot (.) as follows www IN CNAME mytempmail.com.

Posted by mugo, 08-02-2009, 01:33 AM
Ugg. Don't use CNAME, just do an A record. CNAME causes two queries to find the IP. Just darn ugly. It has it's place, but not where you can just as easily do an A rec.

Posted by Think Tank Networks, 08-02-2009, 01:36 AM
I added that directive and htaccess override still doesnt work. Other htaccess things work though.

Posted by InstaCarma_Support, 08-02-2009, 01:38 AM
As for the .htaccess code , try this :

Posted by supportexpertz, 08-02-2009, 01:49 AM
Jordan, Your domain is not resolving to your server properly. You should fix this first, otherwise .htaccess will not make any effect.

Posted by mugo, 08-02-2009, 01:55 AM
You can test this by putting an entry in your c:\windows\system32\drivers\etc\hosts file in the form IPADDRESS hostname like 192.168.5.5 domain.com 192.168.5.5 www.domain.com Save the file, then ping your domain and make sure it's hitting your actual we server. Try again with the browser, if it works, the issue is with you DNS. Fix DNS, remove the two entries in your hosts file.

Posted by Think Tank Networks, 08-02-2009, 02:36 AM
The DNS resolves fine to the www.mytempsite.com but when going to mytempsite.com it resolves to capturetheprize.com (another site on the same server).

Posted by mugo, 08-02-2009, 02:40 AM
It sound like your apache directive is setup to answer to www, but not just the mytempsite.com Add ServerAlias mytempsite.com into your for that domain.

Posted by imorse, 08-02-2009, 02:55 AM
Hye let us know if that solved your problem.. if not lets continue with the possibilities.

Posted by Think Tank Networks, 08-02-2009, 03:03 AM
Aha! That fixed it. Thanks a million



Was this answer helpful?

Add to Favourites Add to Favourites    Print this Article Print this Article

Also Read
Staying a reseller ? (Views: 528)
Mod Security (Views: 547)


Language:

Contact us