• Contact Editorial Team
  • Advertise on YNOT
  • Submit PR
Tuesday, March 24, 2026
  • Login
  • Register
YNOT
  • Home
  • Industry News
    • Porn Star & Adult Talent News
    • Adult Business News
    • Adult Novelty News
    • Adult Industry Legal News
    • Tech News for Adult Webmasters
    • Video Game News for Adults
    • EU News
  • PR Wire
  • Podcasts
  • Industry Guides
  • Newsletters
No Result
View All Result
  • Home
  • Industry News
    • Porn Star & Adult Talent News
    • Adult Business News
    • Adult Novelty News
    • Adult Industry Legal News
    • Tech News for Adult Webmasters
    • Video Game News for Adults
    • EU News
  • PR Wire
  • Podcasts
  • Industry Guides
  • Newsletters
No Result
View All Result
YNOT
No Result
View All Result
Home YNOT Features YNOT University

Coders Corner / Psuedo Sub-Domains With PHP

admin by admin
November 4, 2000
in YNOT University
491
SHARES
Share on FacebookShare on Twitter

What do YOU think about this Script? Add YOUR comments at the end!

Here’s a handy bit of PHP code you can use to simulate Third Level Domains with minimal involvement from your ISP or webmaster.What do YOU think about this Script? Add YOUR comments at the end!

Here’s a handy bit of PHP code you can use to simulate Third Level Domains with minimal involvement from your ISP or webmaster. For those of you unfamiliar with them, Third Level Domains are those whose names replace the commonly used “www.” For example, my main Traffic Filter is at http://www.adultsitelisting.com but I commonly refer to it as http://AdultSiteListing.com without the “www.” It’s the “www.” That I want to replace, rather than eliminate – more for marketing and aesthetics than for “function.”

As I’m about to start working on a new project site, “Asian Adult Site Listing” I asked “Buran” (our intrepid CTO) to setup http://asian.adultsitelisting.com for me – as well as a few other sub-domains while he was at it. He offered me a better solution however, one that was more flexible for the uses I had in mind, and one that would allow me to add, subtract, rename, or redirect these psuedo sub-domains at will.

He renamed my “home page” to “default.html” (it could be any name you wish) and setup a new home page at index.php with the code given below as the only content. Now, all I had to do was add the desired sub-directories (folders) to my site, for example:

http://www.adultsitelisting.com/asian
http://www.adultsitelisting.com/amateur
http://www.adultsitelisting.com/hardcore

Because the DNS settings were not changed (other than the addition of the *.domain wild card and “ServerAlias *.sitename.com” in the Apache config – have your webmaster or ISP do this for you), any browser request for asian.adultsitelisting.com would go to the new index page where the PHP code would look down the path for a folder called “asian” (http://www.adultsitelisting.com/asian) and redirect the surfer to that directory (just as if it was a “true” Third Level Domain). If that directory is not found, the surfer would be directed to the default page, “default.html.” Cool, huh? Try it on your site!

$defaultpage = “default.html”;
$sitename = “adultsitelisting.com”;

if(eregi(“^” . $sitename . “$”, $HTTP_HOST)) {
include($defaultpage);
} else {
$subdomain = explode(“.”, $HTTP_HOST);
$subdomain = strtolower($subdomain[0]);
if($subdomain == “www”) {
include($defaultpage);
} else {
if(file_exists($DOCUMENT_ROOT . “/” . $subdomain)) {
Header(“Location: http://www.$sitename/$subdomain”);
} else {
include($defaultpage);
}
}
}

Now, it’s very important for you to add the standard PHP “containers” to this script. It must start with < ? and end with ? > (I only omitted them from the script here because they kept it from being displayed in the text box).

[ MORE SCRIPTS | CODER’S CORNER >>

Reader Comments on this Article:

Comment by:Summary:
Stephena handy script indeed
michael
All I get is a 403 error

Share196Tweet123
admin

admin

YNOT Admin wields his absolute power without mercy. When he's not busy banning spam comments to hell he enjoys petting bunnies and eating peanut butter. He recommends everyone try the YNOT Mail (ynotmail.com) email marketing platform and avoid giving their money to mainstream services that hate adult companies.

Related Posts

Adult Business News

UK Online Safety Act Cuts Pornhub Traffic 36% as Age Verification Takes Effect

December 13, 2025
Adult Business News

The Cambassador: Lindsey Banks, Flirt4Free and Brand Representation

September 5, 2018
Adult Business News

ImLive’s Mere Menezes Siqueira Manages Models, Makes the Machine Work

August 23, 2018
Corey Silverstein of Adult.law
Adult Business News

Silverstein Says: 3 Legal Issues Cam Companies, Models Must Pay Attention To

August 22, 2018
Load More

SPONSOR

INDUSTRY EVENTS

Currently Playing

YNOT Summit Model Track: Nerds Dig Sexy Gamers

YNOT Summit Model Track: Nerds Dig Sexy Gamers

01:05:46

YNOT Summit Webmaster Track: Understanding Webcam Business Models

00:51:11

YNOT Summit Model Track: Cam Law 101

01:26:24

SPONSOR

POPULAR NEWS

Legendary Performer Micky Lynn Set to Release Documentary

Legendary Performer Micky Lynn Set to Release Documentary

March 23, 2026
Crystal Clark is a Stepmom Who Needs to Chill in Her Latest Release

Crystal Clark is a Stepmom Who Needs to Relax in Her Latest Release

March 23, 2026
Grooby Releases 'TGirl Teasers #60' DVD

Grooby Releases ‘TGirl Teasers #60’ DVD

March 23, 2026

Sponsor

YNOT YNOT

QUICK LINKS:

  • About YNOT
  • Terms of Use
  • Privacy Policy
  • Editorial Team
  • Advertise on YNOT
  • Sitemap

FRIENDS OF YNOT:

  • Best Adult Cams
  • Live Porn
  • Adult Reviews
  • Adult Email Marketing
  • Discounted Porn
  • vr porn sites
  • European Adult Biz Magazine

FRIENDS OF YNOT:

  • Rabbits Reviews
  • XXX Job Interviews
  • Adult Site Broker
  • Femdom
  • Paid Porn Sites
  • Live Sex
  • Cam girl sites
  • AI Girlfriend
  • live porn Vibra Game

Welcome Back!

Login to your account below

Forgotten Password? Sign Up

Create New Account!

Fill the forms below to register

All fields are required. Log In

Retrieve your password

Please enter your username or email address to reset your password.

Log In
No Result
View All Result
  • Home
  • Adult Business News
  • Adult Industry Legal News
  • Adult Novelty News
  • Porn Star & Adult Talent News
  • Tech News for Adult Webmasters
  • Video Game News for Adults
  • Interviews
  • Opinions
  • YNOT Industry Wire
  • Newsletters

Copyright © 2026 YNOT Group LLC.

We use cookies to ensure that we give you the best experience on our website. If you continue to use this site we will assume that you are happy with it.