Jump to content

Dynamic subdomains


gerkintrigg

Recommended Posts

Hi all,

 

I want to have a similar kind of functionality to a lot of sites where I make a sub-folder of a domain (like www.whatever.com/subfolder).

 

I know how to use .htaccess to rewrite (limited knowledge, I admit) but my problem is that I need the server to work out when the folder is a folder and when it is a database record.

 

I've Googled things like "parse PHP in .htaccess" but keep drawing a blank there.

 

How do so many sites (Like Facebook) do it?

 

Thanks,

Neil

Link to comment
https://forums.phpfreaks.com/topic/265601-dynamic-subdomains/
Share on other sites

Either would work for my purpose, but I was thinking a sub folder might be better.

 

Which is easier?

 

The sub folder I was thinking of would be something like:

 

http://www.truro.com/gerkintrigg

 

I suppose a subdomain like:

 

http://gerkintrigg.truro.com

 

would work too, but I'd prefer the first example if possible.

Link to comment
https://forums.phpfreaks.com/topic/265601-dynamic-subdomains/#findComment-1361235
Share on other sites

Use URL rewriting with a "the request doesn't exist" condition. That means virtual folders like "images" or "style" wouldn't work if they were actual directories on your site.

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ...

Link to comment
https://forums.phpfreaks.com/topic/265601-dynamic-subdomains/#findComment-1361356
Share on other sites

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.