I would like to have a .htaccess file that will passively redirect
subdomain.domain.com/folder (with or without a / at the end)
to
"http://www.domain.com/index.php?subdoma ... der=folder"
I would also like it leave it as it is when a file is requested.
Please help, I've seen similar stuff about but I think I just need it all spelling out for me... something in my head is about to pop...
.htaccess change subdomain and subfolder to parameter
Moderator: General Moderators
-
nakeddeveloper
- Forum Newbie
- Posts: 4
- Joined: Wed Feb 25, 2009 10:58 am
-
nakeddeveloper
- Forum Newbie
- Posts: 4
- Joined: Wed Feb 25, 2009 10:58 am
Re: .htaccess change subdomain and subfolder to parameter
For anyone who is interested, I have found what I believe is a more elegant solution by moving the functionality to php...
The .htaccess file just sends everything to index.php now...
And this is my php in the index.php file
I may still need some help as there are likely going to be issues when refering to images or ajax scripts, watch this space...
The .htaccess file just sends everything to index.php now...
Code: Select all
RewriteEngine On
RewriteRule ^(.*)$ index.phpCode: Select all
<?php
$uri = $_SERVER['REQUEST_URI'];
$domain_parts = explode('.',$_SERVER['HTTP_HOST']);
if (count($domain_parts) == 3 && $domain_parts[0]!= "www")
{ // make sure a subdomain is called
$subdomain = $domain_parts[0];
}
?>
Last edited by Benjamin on Tue May 26, 2009 10:37 am, edited 1 time in total.
Reason: Changed code type from text to php.
Reason: Changed code type from text to php.