Runescape Bits & Bytes
https://www.rsbandb.com/forums/

On-the-fly subdomains
https://www.rsbandb.com/forums/viewtopic.php?f=14&t=72142
Page 1 of 1

Author:  Ben [ November 22nd, 2008, 12:30 pm ]
Post subject:  On-the-fly subdomains

The site I'm talking about is on a local network, so the domain won't load what I'm talking about if you aren't me.

My basic idea is that for each folder created in the DocumentRoot, Apache will automatically map it to a subdomain. For example, if I went to example.llamalocal.co.cc, the server would look to see if there was a folder called example, if there was, it would use that for the domain, and if there wasn't, it would use the www folder.

The problem is that when I go to example.llamalocal.co.cc/www, the subdomain folder is mapped to www, not example. Here are the .htaccess files in various directories:

Document root
Code:
RewriteEngine on
RewriteBase /

RewriteCond %{HTTP_HOST} !^llamalocal\.co\.cc(:443)?$ [NC]
RewriteRule ^favicon\.ico$ /www/favicon.ico [L]

RewriteCond %{HTTP_HOST} ^llamalocal\.co\.cc(:443)?$ [NC]
RewriteRule ^www/(.*)$ http://llamalocal.co.cc/$1 [L,R=301]

RewriteCond %{HTTP_HOST} ([^\.]+)\.llamalocal\.co\.cc(:443)?$ [NC]
RewriteCond %{DOCUMENT_ROOT}/%1 !-d
RewriteRule ^(.*)$ /www/$1 [L]

RewriteCond %{HTTP_HOST} ^llamalocal\.co\.cc(:443)?$ [NC]
RewriteRule ^(.*)$ /www/$1 [L]

RewriteCond %{ENV:REDIRECT_subdomain} =""
RewriteCond %{HTTP_HOST} ([^\.]+)\.llamalocal\.co\.cc(:443)?$ [NC]
RewriteCond /%1 -d
RewriteRule ^(.*) %1/$1 [E=subdomain:%1,L]
RewriteRule . - [E=subdomain:%{ENV:REDIRECT_subdomain},L]

RewriteCond %{HTTP_HOST} !llamalocal\.co\.cc(:443)?$ [NC]
RewriteRule ^(.*)$ http://llamalocal.co.cc/$1 [L,R=301]

www folder
Code:
RewriteEngine on
RewriteBase /

# Make sure we're on the right domain.
RewriteCond %{HTTP_HOST} !^llamalocal\.co\.cc(:443)?$ [NC]
RewriteRule ^(.*)$ http://llamalocal.co.cc/$1 [L,R=301]

RewriteRule ^wp\-(.*)$ /blogs/wp-$1 [L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule . /blogs/index.php [L]

blogs folder (Default WPMU htaccess file)
Code:
RewriteEngine On
RewriteBase /

#uploaded files
RewriteRule ^(.*/)?files/$ index.php [L]
RewriteCond %{REQUEST_URI} !.*wp-content/plugins.*
RewriteRule ^(.*/)?files/(.*) wp-content/blogs.php?file=$2 [L]

# add a trailing slash to /wp-admin
RewriteCond %{REQUEST_URI} ^.*/wp-admin$
RewriteRule ^(.+)$ $1/ [R=301,L]

RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule . - [L]
RewriteRule  ^([_0-9a-zA-Z-]+/)?(wp-.*) $2 [L]
RewriteRule  ^([_0-9a-zA-Z-]+/)?(.*\.php)$ $2 [L]
RewriteRule . index.php [L]

<IfModule mod_security.c>
<Files async-upload.php>
SecFilterEngine Off
SecFilterScanPOST Off
</Files>
</IfModule>

Author:  Adbot [ November 22nd, 2008, 12:30 pm ]
Post subject:  Register and login to get these in-post ads to disappear


Page 1 of 1 All times are UTC - 7 hours
Powered by phpBB® Forum Software © phpBB Group
http://www.phpbb.com/