Passing subdomain as parameter

Using a single web hosting account to host multiple sites

Passing subdomain as parameter

Postby outlawbt » Wed Sep 16, 2009 9:29 am

Hello,

I have a kohana framework application with htaccess file like this:


Code: Select all
# Turn on URL rewriting
RewriteEngine On

# Installation directory
RewriteBase /
Options -Indexes

# Protect application and system files from being viewed
RewriteRule ^(application|modules|system) - [F,L]

# Allow any files or directories that exist to be displayed directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

# Rewrite all other URLs to index.php/URL
RewriteRule .* index.php/$0 [PT,L]


I want to make when I access the site via subdomain, like: subdomain.domain.com, the script index.php/profile/subdomain to be executed.
Note: the subdomains don't exist in the cpanel.

Thanks in advance.
outlawbt
 
Posts: 4
Joined: Mon Mar 16, 2009 10:06 am

Postby richardk » Wed Sep 16, 2009 2:10 pm

A variation of FAQ: Virtual sub domains.

Note: the subdomains don't exist in the cpanel.

The FAQ wrote:Note: this will only work if you have DNS for the sub domains (probably Wildcard DNS) and the server configured to send the requests to the same document root.


The code would be something like
Code: Select all
Options +FollowSymLinks -Indexes

RewriteEngine On

RewriteRule ^(application|modules|system) - [F,L]

RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteCond %{HTTP_HOST} !^www\.example\.com$ [NC]
RewriteCond %{HTTP_HOST} ^([^\.]+)\.example\.com$ [NC]
RewriteRule ^.*$ /index.php/profile/%1 [QSA,L]

RewriteCond %{SCRIPT_FILENAME} !-f
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteRule ^.*$ /index.php/$0 [QSA,L]

Where should a request to sub.example.com/something go?
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am


Return to Domain Handling

Who is online

Users browsing this forum: No registered users and 20 guests

cron