PHP forward subdomain to other webpage (via referral url)

http referer header php
add referrer to url
$_server['http_referer']
referrer url
set referer header
https referer
http referer php
redirect without changing url php

I've only used PHP a few times, so I need little help.

I'm looking for a way to read the subdomain the user are visiting.

If they for example visit (anything).mysite.com they will be forwarded to myothersite.com/(anything)

Is this possible with php?

I don't have access to https.conf

Update:

Apparently it's my web on a shared server, so when forwarding a subdomain to the domain, it does this c via iframe.

This causes the server uri to be faulty, however, just changing the server_uri to http_referer didn't work.

Anybody got any idea how to solve this?


Solved it!

The question changed during the investigation, so I won't 'award' myself, but give it to the answer that worked on my start question..

How to redirect VIA REFERRAL from subdomain on one site to other sites subdirectory

This can be used to forward a subdomain(s) to sites running thru iframe.

  <?PHP

    $REFERRER = $_SERVER['HTTP_REFERER']; 


    $domain = substr($REFERRER, strpos($REFERRER, '://')+3); 
    $domain = substr($domain, 0, strpos($domain, '/')); 
    // This line will return 'en' of 'en.example.com' 

$subdomain = substr($domain, 0, strpos($domain, '.'));   
    header("Location: https://server2.com)/'.$subdomain");

    ?>

Oh one more important thing I discovered, make sure the site don't display anything before calling the header function, that won't work!

How can I pass referrer header from my https domain to http , Sadly you can not referrer on HTTPS to sites using HTTP. <a href="http://www.​yours.com/out.php?www.other.com">www. page on another domain and still pass the first page's URL as a referrer using the following technique. the HTTP version of the origin domain ie. http://example1.com/origin.html. How can I use a PHP script to redirect a user from the url they entered to a different web page/url? Under PHP you need to use header() to send a raw HTTP header. Using headers() method, you can easily transferred to the new page without having to click a link to continue. This is also useful for search engines.


You can try with this procedural code and adapte it to your project

    $host = explode('.', $_SERVER['HTTP_HOST']);
    $subdomain = null;
    if(count($host) > 2) //If it has subdomain
    {
            $subdomain = $host[0];
    }
    header('Location: http://myhost.com/'. $subdomain);

Redirect problem using HTTP_REFERER - PHP, Hi, I'm using this code to redirect visitors who are coming from another site (​clicking I can track them: $referrer = $_SERVER['HTTP_REFERER']; if ( strstr($​refe… directory or subdomain from example.com, not only a specific url in example.com Make sure you put this before any output (html), otherwise it won'​t work. I named the file as redirect.php I must have named it index.php :) – jeet.chanchawat Jul 19 '12 at 4:57 Try "redirects" from cpanel and add the URL myblog.blogspot.in for your subdomain. If godaddy is not helping try reading another hosts blogs to create.


Please use virtualhosts(httpd.conf) via apache server. This is a better option than php redirection.

<VirtualHost *:80>
  ServerName abc.example.com
  Redirect / http://www.example.com
</VirtualHost>

<VirtualHost *:80>
 ServerAdmin webmaster@example.com
 DocumentRoot "/var/www/html/example_folder"
 ServerName example.com
 ErrorLog "logs/example.com-error_log"
 CustomLog "logs/example.com-access_log" common
</VirtualHost>

How to Redirect a Domain without Changing the URL, Thanks for asking about masking your subdomain URL. We cannot change your website code for you through the Support Center. am able to url forward to other ip based application. but i cant restrict the application to open by ip Hi i am redirecting my pages that are not found to error404.php. To show contents from DomainB but show DomainA url there are 2 options: 1. Park domain. If DomainB is your primary domain name, just add DomainA as a Parked Domain. 2. Redirect Using .htaccess file. This method is: Redirect and keep everything after the URL. The first option will show all of the same content on one URL as you would another.


How to redirect to another webpage using a fake referrer, http://www.co.cc/blogger/blogger.php on how to do this. [update] Use a curl How can I redirect all pages of my website to one URL only? 828 Views · How can I How do I redirect one URL to another based on a subdomain? 1,382 Views. To tell website visitors and search engines that your web page has permanently moved to a new location with equivalent content use a 301 redirect. The code “301” is interpreted as “moved permanently”.


parse_url - Manual, Partial URLs are also accepted, parse_url() tries its best to parse them $url = '​http://usr:pss@example.com:81/mypath/myfile.html?a=b&b[]=2&b[]=3# Here's a good way to using parse_url () gets the youtube link. This will be accurately detected as the host name instead of "path" as in all other if (document.referrer) { Under If the URL matches, enter the URL or URL pattern that should match the rule. Learn more about wildcard matching. Next, click Add a Setting. Choose Forwarding URL from the drop down menu. Click Select Status Code and choose 301 (Permanent Redirect) or 302 (Temporary Redirect). Enter the destination URL. To finish, click Save and Deploy.


How can I setup a redirect?, You can easily redirect your visitors from one page to another with the help of the Redirects feature. This also works for subdomains or completely different websites. Notes: Redirecting to a website without an SSL certificate but using the HTTPS PHP · Browse 13 articles Referrals · Browse 4 articles  You can also redirect your domains by creating PHP or HTML index file in the document root folder of your domain. This article provides examples for both programming languages that will help you to complete that redirection. Using CNAME DNS records. This DNS method will allow you to redirect your subdomains to other domains/subdomains (example