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
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
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
Share on other sites

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.