Webmaster Forum

Go Back   Webmaster Forum > Web Development > Coding Forum

Coding Forum Problems with your code? Discuss coding issues, including JavaScript, PHP & MySQL, HTML & CSS, Flash & ActionScript, and more.


Reply
 
Thread Tools Display Modes
Share |
  #1  
Old 08-08-2006, 07:36 AM
tosaha tosaha is offline
Member
 
Join Date: 08-02-06
Posts: 39
iTrader: 0 / 0%
Domain Redirection

(This is posted in the Domain forumbut I thought I might get an answer here as well.)

Hey all, I have what I'm sure is a simple issue though oddly enough I'm not finding the answer on my own so I'd thought I'd ask.

I have two domain names for my website. However, I would like to have a redirection set up in the index file where if someone types in firstdomain.com it directs them to firstdomain.com/index2.html and if they type seconddomain.com it sends them to seconddomain.com/index3.html.

Would anyone know of any simple script that would do this? I tried a javascript redirection but that just loaded the content on my page for a second before it redirected me. And I tried to add a php include command before the head content of my page but that didn't work (don't know why).

Any help would be appreciated,

Tosaha
 
Reply With Quote

Advertisement

Advertisement

  #2  
Old 08-08-2006, 07:40 AM
JuggoPop's Avatar
JuggoPop JuggoPop is offline
Senior Member
 
Join Date: 10-09-03
Posts: 4,278
iTrader: 0 / 0%
1. please don't post multiple copies of the same question.

2. what are you trying to do exactly? are you trying to just get the user to the other address or are you trying to hide content in the first page and move the user past it quickly?
 
Reply With Quote
  #3  
Old 08-08-2006, 09:32 AM
tosaha tosaha is offline
Member
 
Join Date: 08-02-06
Posts: 39
iTrader: 0 / 0%
Sorry about that. I won't double post again.

In regards to my question though I'm trying to direct a user to a specific file depending on what domain they type. The page with the redirection code doesn't have anything in it; it's purely to direct the user to the right page.
 
Reply With Quote
  #4  
Old 08-08-2006, 09:47 AM
JuggoPop's Avatar
JuggoPop JuggoPop is offline
Senior Member
 
Join Date: 10-09-03
Posts: 4,278
iTrader: 0 / 0%
do you have cpanel on your hosting?
 
Reply With Quote
  #5  
Old 08-08-2006, 10:01 AM
tosaha tosaha is offline
Member
 
Join Date: 08-02-06
Posts: 39
iTrader: 0 / 0%
I do. But I host with Omnis and I don't see any option which allows me to do this.
 
Reply With Quote
  #6  
Old 08-08-2006, 10:02 AM
JuggoPop's Avatar
JuggoPop JuggoPop is offline
Senior Member
 
Join Date: 10-09-03
Posts: 4,278
iTrader: 0 / 0%
http://www.v7inc.com/tutorial/cpanel...edirecturl.htm
see if you can do as this tutorial shows.

if not you will have to do the redirects yourself.
let me know and Ill try to explain further.
 
Reply With Quote
  #7  
Old 08-08-2006, 10:27 AM
pairbrother pairbrother is offline
Banned
 
Join Date: 02-17-06
Location: Sacramento, California
Posts: 133
iTrader: 0 / 0%
nice tut there juggopop

btw u can do it through javascript also. Create index.html files on both the sites in the /www folder.

The content of index.html:
for firstdomain.com
Code:
<script> location.href="index2.html"; </script>

and for seconddomain.com
Code:
<script> location.href="index3.html"; </script>
hope tht helped
 
Reply With Quote
  #8  
Old 08-08-2006, 10:30 AM
JuggoPop's Avatar
JuggoPop JuggoPop is offline
Senior Member
 
Join Date: 10-09-03
Posts: 4,278
iTrader: 0 / 0%
I was just going to suggest the htaccess redirects written by hand, if cpanel doesn't give the option to help.
 
Reply With Quote
  #9  
Old 08-12-2006, 06:53 AM
helloworld's Avatar
helloworld helloworld is offline
Contributing Member
 
Join Date: 06-29-06
Posts: 71
iTrader: 0 / 0%
A redirect will not help.

If I understand you right, you are looking for:

Both domains point to the index page

The index page finds out what domain was requested.

If domain A, redirect to index2.html

If domain B, redirect to index3.html

The problem here is index needs to know what domain you requested.

Usually this is done through dns forwarding, or a virtual server.

But you can give this a shot,

Code:
<?php //////© S. Benjamin, GoStubby.com ///// Can't have "http" and, or "WWW" - It "must" be in this format: "domain.tld" $D1 = 'mydomain.com'; ////Main Domain $D2 = 'mydomain2.com'; ////Sec. Domain $P1 = 'index2.html'; ////Main Domain redirected to page $P2 = 'index3.html'; ////Sec. Domain redirected to page /////////Do Not Edit From Here Down////////////// if (preg_match ("/$D1/i", $_SERVER['HTTP_HOST'])){ header("Cache-Control: no-cache, must-revalidate"); header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); header("HTTP/1.1 301 Moved Permanently"); header("Location: /$P1"); exit; } else { header("Cache-Control: no-cache, must-revalidate"); header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); header("HTTP/1.1 301 Moved Permanently"); header("Location: http://".$D2."/$P2"); exit; } ?>

Last edited by helloworld; 08-12-2006 at 06:59 AM.
 
Reply With Quote
  #10  
Old 08-13-2006, 09:37 AM
tosaha tosaha is offline
Member
 
Join Date: 08-02-06
Posts: 39
iTrader: 0 / 0%
Sorry it took so long for me to reply, actually I've been trying some of the suggestions give in this forum.

I had trouble with .htaccess since, unknowingly, I didn't actually have access to that file through my host. That led me to try and create one which I eventually discovered to be useless since there was already one registered for my site.

At any rate, I ended up trying helloworld's script and it works like a charm! So thank you very kindly for your help. Honestly, as this was my first problem posted here, I was a little wary about how likely it was random people would find the time to help me. It turns out people are a lot more friendly than you think.

But enough of my rambling, thank you again helloworld!

Tosaha
 
Reply With Quote
  #11  
Old 08-13-2006, 01:17 PM
helloworld's Avatar
helloworld helloworld is offline
Contributing Member
 
Join Date: 06-29-06
Posts: 71
iTrader: 0 / 0%
Your welcome,

Was surfing the board and happen to run across the post, so I figured I'd write it up for ya. This place has alot of helpful people.

I don't think they understood what you where trying to acomplish.

Have a great day!
 
Reply With Quote
  #12  
Old 08-13-2006, 01:55 PM
helloworld's Avatar
helloworld helloworld is offline
Contributing Member
 
Join Date: 06-29-06
Posts: 71
iTrader: 0 / 0%
BTW these two lines are not needed.

Code:
header("Cache-Control: no-cache, must-revalidate"); header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
They are just there to stop the visitors browser cache from storing the new location.

This could have a negative impact on search engines so i suggest you remove it and see if it will function without it.

The reason I added it was, I didn't want it storing in the browser cache and when domain 2 was typed it ignore the script and go to the page for domain 1.

Now that I think about it, I really don't think it needs it.
You may want to check it out and see.

Last edited by helloworld; 08-13-2006 at 02:01 PM.
 
Reply With Quote
  #13  
Old 08-14-2006, 07:05 AM
JuggoPop's Avatar
JuggoPop JuggoPop is offline
Senior Member
 
Join Date: 10-09-03
Posts: 4,278
iTrader: 0 / 0%
good information helloworld.
 
Reply With Quote
  #14  
Old 08-14-2006, 11:30 AM
tosaha tosaha is offline
Member
 
Join Date: 08-02-06
Posts: 39
iTrader: 0 / 0%
Not a problem helloworld. As it stands though I haven't had any issues with the script... though I was wondering about those lines before.

Thanks again!

Tosaha
 
Reply With Quote
  #15  
Old 08-14-2006, 08:58 PM
helloworld's Avatar
helloworld helloworld is offline
Contributing Member
 
Join Date: 06-29-06
Posts: 71
iTrader: 0 / 0%
thanks JuggoPop
 
Reply With Quote
Go Back   Webmaster Forum > Web Development > Coding Forum

Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Domain Redirection tosaha Domain Name Forum 2 08-13-2006 09:40 AM
cPanel Redirection = 301 redirection? sixty6 Web Hosting Forum 0 08-09-2006 08:07 PM
Domain redirection DragonEye Reseller Hosting 1 02-02-2006 12:46 AM
Redirection Problem! webexpertz SEO Forum 5 08-18-2005 12:24 AM


V7N Network
Get exposure! V7N I Love Photography V7N SEO Blog V7N Directory


All times are GMT -7. The time now is 05:01 AM.
Powered by vBulletin
Copyright 2000-2014 Jelsoft Enterprises Limited.
Copyright © 2003 - 2018 VIX-WomensForum LLC