How can I make a virtualhost accessibile through http://eastcoastrolling.info as well as www.eastcoastrolling.info ?
And don`t start with the things like buy the domain haha :D
Replies (13)
You should have a record in
Reply 1Additionally you may need to
Reply 2Additionally you may need to go into your Virtual Server Options > Networking and Addresses and add your www in the Alternate virtual server names. I don't know if that is required but I needed to do that for my virtual hosts.
Thanks anyway
Reply 3Yeah I'm sure they do too. Just you seem pretty knowledgable and thought you may know off the top of your head.
I just had a quick google and this looks pretty straight forward (for anyone else who is interested).
Never used lighthttpd
Reply 4I never used lighthttpd but I would guess they have virtual hosting just like Apache.
That looks like a much better way of doing it!
Reply 5Nice work Neil!
Off the top of your head do you know if a similar config is easily done for Lighhtpd? No dramas if you don't, because I could always google it but I'm feeling lazy (and I don't need to know right now cause my redirect page works fine, just wondering for future reference cause your way looks much better).
Redirect
Reply 6I add a virtual host like this to my main apache conf file:
I prefer to do it server side and not in javascript. That way all browsers will work.
<VirtualHost *:80> ServerName www.unmeteredvps.net ServerAlias *.unmeteredvps.net Redirect permanent / http://unmeteredvps.net </VirtualHost>
Ok. Redirect
Reply 7step by step ?
Here's a redirect page that I use
Reply 8There are many ways to redirect pages. For a full rundown and pros and cons of different methods some online research is the best bet. Google will give you many ideas and approaches to the issue.
I have successfully used javascript and I am happy to share the code I use (as I robbed it from someone online already anyway). This works fine for me, but requires javascript to be enabled (it will give a warning if javascript is disabled/not available). This page will need to be saved as index.htm on the www root of the server which www.example.com points to.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Redirecting to Correct Server ...</title>
<meta http-equiv="REFRESH" content="5;url=http://example.com">
</head>
<body>
Now redirecting you to the correct server ... Please Wait ...
<br><br>
<noscript>Javascript is required to access this server - please enable to proceed</noscript>
<br><br>
Some more informative text here if you so desire<br>
</body>
<script language="javascript"><!--
location.replace("http://example.com")
//-->
</script>
</html>
Hope that helps.
Redirect or alias?
Reply 9You have two options:
You can set up a redirect. This will make any url on www.example.com reload and go to example.com. That means all urls will be on the example.com domain.
You can alias www.example.com as part of the virtual host of example.com. This will still show www.example.com in the browser's location bar.
The redirect is better for Google indexing since they will index one url and not two.
Keep In Mind
Reply 10Well , I want www.example.com to point to example.com
More precise ? I didn`t get much from what you said earlier , sorry.
Overgeneralized
Reply 11I overgeneralized. What I meant to say is that by setting up a wildcard alias for each of my domains in the apache conf file, I can control which subdomains go to the server (And potentially other servers) by setting the DNS entries to point to them. I can even use a wildcard dns entry to point all unmatched subdomains to a server.
Lets take an example:
I can have the conf file with a virtual host for *.example.com on two different servers.
Now, if I set these entries in DNS:
a.example.com points to server1
example.com points to server2
b.example.com points to server2
*.example.com points to server1
I do not change the apache conf file to move the subdomains around. The DNS entries control where they point.
exact
Reply 12Can you be more precise ?:) How can I control everything using DNS ?
I use a wildcard alias
Reply 13When I do a virtual host like that, I set ServerName to eastcoastrolling.info and ServerAlias to *.eastcoastrolling.info
After that, I can control everything using DNS.
Hope this helps.
You should have a record in your DNS pointing www.eastcoastrolling.info to eastcoastrolling.info