View Full Version : Redirecting without address changing
markblair
04-17-03, 05:34 AM
Hopefully someone will know how to do this. I have a few domains that I've setup to automatically redirect to another directory on my main domain. I've done this mainly so I could own those domains and in some cases I eventually will do something with them. But rather than having them display an error when selected, I have them redirect elsewhere. To do this, I use the following script:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>domain2.com</title>
<script>
window.location.replace("http://www.domain.com/domain2")
</script>
</head>
<body bgcolor="#FFFFFF">
</body>
</html>
...In this example, I have domain2.com. I want it to redirect any visitors to domain.com/domain2. This works nicely but there is one problem. The address line in the browser will also change to show domain.com/domain2 instead of just domain2.com. Does anyone know how I can modify this script, or use another one, to keep the address line as domain2.com when in fact the visitor is viewing domain.com/domain2?
Most of the time, the visitor is just viewing a page with general information and a full website is not needed. If anyone knows what I need to do to get the address line in the browser to remain the same as the site they entered (in this case domain2.com), that would be great.
I appreciate all feedback regarding this request.
suppleSupport
04-17-03, 05:43 AM
Are you on Cpanel? Addon domains do just that.
markblair
04-17-03, 05:47 AM
Yeah, I've seen that about CPanel. However, I'm on Ensim version 3.1.x.
If you want to redirect w/o hiding the new address, use meta refresh instead of javascript! Many IE users disable javascript for security reasons. For example:
<html>
<head>
<meta http-equiv="refresh" content="0; URL=http://www.domain.com/domain2/">
</head>
</html>
If you want to redirect to a URL on another server and hide the address from inexperienced computer users, frame it (and make the page's default link target _top of course).
If you want the domain to exactly mirror another one that you're hosting, use Ensim's domain aliases.
If you want the domain to show a specific page that is on your server, but isn't the index of another domain, then either symlink it (may require telling Apache to follow symlinks in .htaccess), or, better yet, set it up it httpd.conf outside of Ensim's system.
http://www.zoneedit.com/
You can point the domain to their name servers and then specify a IP addy for the domain to go to.
Mark, it doesn't sound like DNS hosting is the problem...
Chicken
04-17-03, 04:00 PM
I'd look into doing this via apache and redirecting via a .htaccess file, though I haven't done this in a while and can't recall if it keeps the URL in the browser. The true, honest to goodness way of doing this is in httpd.conf and alter the directory that the domain resolves to. If domain2 is set up on the server, you'd simply type the directory you want it to resolve to (domain.com/domain2), but I'm not sure if Ensim would just overwrite any manual changes you make, as some cp's will.
Ensim won't overwrite it. They nicely set it up so that every site has its own configuration file in a directory dedicated to them and the main httpd.conf just Include's that directory. Now if you edit one of those files your changes will get overwritted if you edit the site's configuration, but in this case the site domain wouldn't even be added as a site in Ensim, so that won't be a problem.
markblair
04-17-03, 06:55 PM
Actually, domain.com and domain2.com are going to be added to the same server. I just need to make sure anyone visiting domain2.com is actually looking at domain.com/domain2. The person that needs this doesn't want to login to two different accounts when domain2.com will be a very basic page.
It does sound like httpd.conf is the way to go. Anyone know of a good resource showing what to edit that with? This will be the first time I've had to modify that file.
Thanks again,
suppleSupport
04-18-03, 02:15 AM
Add something like this to httpd.conf:
<VirtualHost 123.123.123.123>
BytesLog domlogs/sub.domain1.com-bytes_log
ServerName sub.domain1.com
ServerAlias domain2.com *.domain2.com
ServerAdmin wwwadmin@domain1.com
DocumentRoot /home/domain1username/public_html/domain2
CustomLog domlogs/sub.domain1.com combined
ScriptAlias /cgi-bin/ /home/domain1username/public_html/domain2/cgi-bin/
UseCanonicalName off
User domain1username
Group domain1group
</VirtualHost>
SSH in and use pico (easier) or vi.
Chicken
04-18-03, 07:19 AM
The key thing you want to look for is:
DocumentRoot /home/domain1username/public_html/domain2
This is basically telling the server where to go.
suppleSupport
04-18-03, 09:43 AM
Yup, also from what I remember the path to public_html in Ensim is very different to what it is in Cpanel.
markblair
04-18-03, 10:56 AM
Yes, the path is definitely different as I can tell the one listed is not familiar. However, I will modify that and post here the results of how it worked. Thanks again, everyone.
Originally posted by no1v2:
If you want to redirect w/o hiding the new address, use meta refresh instead of javascript! Many IE users disable javascript for security reasons. For example:
If you want to redirect to a URL on another server and hide the address from inexperienced computer users, frame it (and make the page's default link target _top of course).
If you want the domain to exactly mirror another one that you're hosting, use Ensim's domain aliases.
If you want the domain to show a specific page that is on your server, but isn't the index of another domain, then either symlink it (may require telling Apache to follow symlinks in .htaccess), or, better yet, set it up it httpd.conf outside of Ensim's system. You can put his code in a frame, and the user won't see the address he/she is redirected too.
markblair
04-19-03, 04:33 PM
Actually, that's how I have it right now and it does work -- in the frame. However, I still want to try using httpd.conf to see how that works as well.
Chicken
04-19-03, 06:56 PM
Originally posted by markblair:
...to see how that works as well.
i think he knows it will work, just... well... there's not much to how it will work other than you'll see the URL in the addy bar and the pages in the browser :D
markblair
04-19-03, 07:07 PM
When I referred to "how" I simply meant I want to see the difference of setting up frames pages versus the httpd.conf setup. I don't anticipate a difference in what I see, just in how I set it up. I know it will work, though. :)
vBulletin v3.5.4, Copyright ©2000-2012, Jelsoft Enterprises Ltd.