LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 10-11-2005, 04:11 PM   #1
novice22
LQ Newbie
 
Registered: Jan 2004
Posts: 17

Rep: Reputation: 0
Question about PHP programs


Hi,

I am not a php coder, but I am in the process of learning enough to create my own website. If there are any experts out there, or anyone with some good knowledge of PHP, here goes a question.

Is there a way for PHP to redirect visitors based on the domain name that they put in? If so, could someone give me a sample code for that? or at least tell me some of the commands that would be required.

The thing is that I am trying to make a decision between two hosts: One offers 'domain pointing' not 'domain add-ons' -- but this is a good host, that I know has proven to be up most of the time and fast access. Then there is another host that offers domain ad ons, but has failed me on occasions -- it was slower, for reasons unknown.

So, if PHP has a way to redirect based on domain, then I would choose the reliable one and create a page for redirecting the domains. I do not want to pay for perl programs, or cgi's that might do this, that is why I am looking into PHP.
 
Old 10-11-2005, 04:55 PM   #2
Knazer
LQ Newbie
 
Registered: Oct 2005
Location: Sundsvall, Sweden
Distribution: Slackware 10.2, Kernel 2.6.13, KDE 3.4
Posts: 1

Rep: Reputation: 0
I'm not exaclty sure what you wan't to do, but here is a PHP function that will redirect your visitor to another adress:

Code:
<?php 
 header( 'Location: http://www.newurl.com' ); 
?>
You can read more about this function att www.php.net/header

Don't know if this works for all browsers but it has always worked for me.

I hope this will get you started.
 
Old 10-11-2005, 06:51 PM   #3
clb
Member
 
Registered: Sep 2004
Location: UK
Distribution: Ubuntu
Posts: 117

Rep: Reputation: 16
You may be able to get the url from the HTTP_HOST variable like so
PHP Code:
$domain $_SERVER['HTTP_HOST']; 
Then you should be able to play around with the string returned to get either the domain or the subdomain.
 
Old 10-11-2005, 08:18 PM   #4
novice22
LQ Newbie
 
Registered: Jan 2004
Posts: 17

Original Poster
Rep: Reputation: 0
Thanks a lot for the help...

Thanks for the help, I will make use of the info here.
 
  


Reply



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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
php-gtk programs don't work nemeli Linux - Software 1 03-03-2005 03:43 AM
Question about linking programs Darx Linux - Newbie 5 05-27-2004 06:17 AM
Installing new programs question rhodan Slackware 9 05-17-2004 03:29 PM
Exam question programs Richey Linux - Software 0 02-05-2004 06:37 AM
trouble installing php caching programs JustinHoMi Linux - Software 0 02-24-2002 06:05 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 01:26 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration