Jump to content

Recommended Posts

Ok, so let's say my website is bob.com - fine. Well, I want to have sam.com also, but can't afford to pay for Deluxe hosting. So I get the domain, but I forward sam's DNS servers to point at Bob, with masking on.

What I'm looking to do is to identify what the person typed in - i.e., the original, unmodified URL. Here's what I have currently:

function get_redirect_target($url)
{
    $ch = curl_init($url);
    curl_setopt($ch, CURLOPT_HEADER, 1);
    curl_setopt($ch, CURLOPT_NOBODY, 1);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    $headers = curl_exec($ch);
    curl_close($ch);
    // Check if there's a Location: header (redirect)
    if (preg_match('/^Location: (.+)$/im', $headers, $matches))
        return trim($matches[1]);
    // If not, there was no redirect so return the original URL
    // (Alternatively change this to return false)
    return $url;
}

$path = $_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
echo get_redirect_target($path);

The main problem here is that it's VERY slow. I'm also often getting a 500 error. Anyone have any ideas?

Link to comment
https://forums.phpfreaks.com/topic/309718-need-help-with-redirect/
Share on other sites

I can't afford the deluxe hosting.  With the deluxe hosting, I can have an infinite number of websites under one hosting plan.  With the basic hosting, I can only have one site hosted.  So, what I have is the DNS pointing the second domain to the first; if the user types "www.sam.com," they still go to "www.bob.com," but they see the content for "www.sam.com" instead, just as if it was its own site.

If you told your DNS provider that it should redirect from one to the other, that's wrong. If you told them to alias, that's potentially okay, depending on how they do the aliasing.

Can you post the actual domain name? The second "sam.com" one.

What they did was host mullins-storage.com on their servers, and the webpage they present uses an iframe to load br-storage.com. That's not good. It also doesn't support what you want to do.

You need to point both domains to the same server, then make sure your web server tries to serve both sites... however they need to be served. I don't know what "deluxe hosting" is but you're probably getting close to it.

I thought that redirecting (or alias, or whatever) was the right way.

 

If it's not an alias or redirecting, there won't be anywhere for it to go.

The br-storage site goes to the br-storage site; the mullins-storage ALSO goes to the br-storage site.  Isn't that what you said?  That both domains should go to the same site?  I'm confused.  Can you explain exactly what you mean?

In my very first post here I questioned why you were even having it redirect at all. I haven't changed my mind since then.

You know how br-storage goes to your server? The server that has the website and all that? mullins-storage needs to do exactly the same thing. No redirects.

How is that possible?  Each server can only serve ONE website.  Mullins is on the same server, but can't have its own website.  Therefore, there HAS to be some sort of redirect or alias or whatever, so that, with the proper code, I can detect what people were searching for - and thus make it LOOK like there are two separate websites, when, in fact there's only one.

AFAIK, what I'm trying to do IS possible - I'm just not sure what's wrong.

My company has multiple hosting plans.  The basic plan is one website.  I can have multiple domains, but only one hosted site.  I can do DNS forwarding on the 2nd domain, or an alias on the 2nd domain.  If I pay extra, I can get the deluxe hosting - which can have as many websites hosted on the server as I care to dream up.  What I wanted to have happen was to have my singleton website try to determine what it was the person had typed.  If they typed www.mullins-storage.com, then - instead of bringing up the index.php for www.br-storage.com, it would bring up a slightly different index.php geared toward www.mullins-storage.com instead.

 

If you're telling me that this isn't possible, then I'll have to bite the bullet and pay for the deluxe hosting, and have two individual websites.

1. The DNS for both domains needs to be the same IP address to the server - no aliases, no redirects, just a basic DNS setup
2. The web server needs to be configured so that both domains go to the same "site"

The second part you may or may not be able to do, depending what you have access to. It's quite possible they may have locked this part of the process down enough so that clever people wouldn't be able to get around their paywall. Or maybe they didn't.

Who are you using as a hoster?  The ones that I reviewed prior to making my selection many years ago all offered sub-domains which is pretty much what you can do I believe.  I have two function domains that may call each other but I never do it.  They are distinct things and don't need to share anything.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.