Jump to content

Include Subdomain name only in page


cinos11

Recommended Posts

What i need help on is getting php to include the website name ex: subdomain.domain.com

Then what it will do is strip ".domain.com" so that way it only shows subdomain as text on the page.

 

I will be using this for my wildcard subdomains. That way if someone puts in bobby.domain.com it will show bobby as the text on the page.

Link to comment
https://forums.phpfreaks.com/topic/191947-include-subdomain-name-only-in-page/
Share on other sites

I don't exactly understand what you asking here. This doesn't seem like it has anything to do with PHP per se. You can use mod_rewrite (Apache module) to redirect the sub-domain to a page that could do this, but this isn't really relative to PHP since the only PHP involved would be...

 

echo $_GET['subdomain'];

If you can confirm it's the mod_rewrite section you need help with I can move the topic to the appropriate board.

 

NB: This will also only work if the host (or you if your in control of it) has the Nameserver set up to pass all sub-domains through.

The post above cags will not work because i when the page loads with any random subdoman such as: bob.domain.com,jake.domain.com,dog.domain.dom. That it will show only bobby because the PHP only says to use that then explode part of it.

 

For the above i tried echo $_GET['subdomain']; on my website and nothing showed. I think what that php code says is what i need but its not working. As for your note above saying will only work etc.  Yes im in control of my website, as its hosted on my computer. And all non setup subdomains are set up to be redirected to one webpage using a wildcard of *.domain.com

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.