Add "www." to domain on load?

D-MaN

New Member
Messages
12
Reaction score
0
Points
0
I was wondering how to configure my setup so that when a user enters the domain into thier browser without the "www." part, the page will load as "www.domain.com" rather than "domain.com".

Example: I'm using Firefox 2.0.0.12 on WinXP SP2. If I type in "google.com" and hit enter, FF takes me to "www.google.com". This is, ideally, what I want to happen with my domain.

My domain is "mad-robot.ca". In the x10 control panel, my account is setup to use the domain "mad-robot.ca". When I enter "mad-robot.ca" into my browser, it takes me to "mad-robot.ca" and doesn't correct it to "www.mad-robot.ca".

So, figures I, maybe I just need to include the "www." part in the x10 control panel. So I go back and enter "www.mad-robot.ca" as my domain and apply. After doing that, "www.mad-robot.ca" in the browser works fine and all, but just entering "mad-robot.ca" in the browser gives me a "Server not found" error. :p

As it stands, I've set the x10 control panel back to using "mad-robot.ca" and it still doesn't add the "www." part when loaded in a browser. Massive reps and huge thank-yous to anyone with info on this, or suggestions to where I should look next. If I've failed to explain something or you need more information, post or PM, I'll get back to you ASAP. Many thanks for reading this far!
 
Last edited:

taekwondokid42

New Member
Messages
268
Reaction score
0
Points
0
I'm a little confused on the problem, so here are my answers to each of my interpretations:


1st interpretation: You own one of the domains above (either with the w's, or without them), but you want both to work. What you need to do is buy the other one (so you now own both), and park one domain to the other. That way, if you type in the wrong one, it re-directs you to the right one.


2nd interpretation: You own both, but you have not parked one to the other. To park one to the other, go to your cPanel, and under "domains," look for 'parked domains.' Then, follow the video tutorial if you are still not sure what to do.


If both of these are incorrect, please re-explain the problem, and I'll try to help.
 

kajasweb

New Member
Messages
1,723
Reaction score
0
Points
0
Just add the following files to your .htaccess

Code:
RewriteEngine on
RewriteCond %{HTTP_HOST} ^yourdomain\.com$ [NC]
RewriteRule ^(.*)$ http://www.yourdomain.com/$1 [L,R=301]

Thats it. Users typing-in yourdomain.com will be redirected to www.yourdomain.com.
 

D-MaN

New Member
Messages
12
Reaction score
0
Points
0
kajasweb got what I was after, good call mate, thanks for the help. That's exactly what I was trying to do. I figured that it had something to do with .htaccess file, but all my google searches came up empty.

UPD
So, my n00b skills are showing here, I went into the cPanel file manager and loaded the .htaccess file into the "Code Editor", copy+pasted the above code into the file, saved it. Typed the addy into the browser. Page loads fine, but didn't get the "www." portion added. Suggestions?
 
Last edited:
F

Fahad

Guest
kajasweb's way doesn't show the user that the redirect has happenned
Why not add a header("Location: site.with.the.www.prefix/page") to every page?
 
Last edited by a moderator:

Xemnas

New Member
Messages
812
Reaction score
0
Points
0
Using cPanel you can just set up a redirect on your primary domain to itself, but with the www. added. Make sure www. redirection is disabled on it and that it uses wild-card redirection.
 

D-MaN

New Member
Messages
12
Reaction score
0
Points
0
Ok, thanks to all who have responded so far; I've now run into a different problem...

I attempted Xemnas's solution, but cPanel gave me the following error when trying to create the redirect:
Code:
Apache detected an error in the Rewrite config.

Syntax error on line 4 of /home/doherty/public_html/.htaccess.t6XUUSQD9dZER97Y_87BVbY6T7NpPnY9:
RewriteCond: bad flag delimiters

Please try again.

*sigh* any suggestions on this one? As always, your guys' and gals' help is really appreciated!

UPD
Heh heh, that error was all my fault. There was some junk code left in my .htaccess file that I didn't get rid of from the last time I was tinkering with it. Turns out that the left-over code was screwing up cPanel when it tried to add the redirect. Anyways, everything is working perfectly now, just the way I want it. Thanks again to all those who helped out! Rep given! Take care and have fun!
 
Last edited:

D-MaN

New Member
Messages
12
Reaction score
0
Points
0
So, the forum isn't letting me edit my previous entry; apologies for the double post.

Everything was working fine using Xemnas' redirect solution. However, after a fresh install of Wordpress using Fantastico, going to the site either www.mad-robot.ca or mad-robot.ca gives me this error:


The page isn't redirecting properly

-Firefox has detected that the server is redirecting the request for this address in a way that will never complete.

*This problem can sometimes be caused by disabling or refusing to accept cookies.

Disabling cookies ans clearing my browser cache don't seem to help. I've tried to load this on several different computers now in both FF and IE. Any suggestions?

ALSO, I've removed the re-direct for the time being so I can continue to work on the site, if you want me to enable it again, post or PM me. Thanks again.
 
Last edited:
Top