Forum Moderators: phranque
[edited by: Ocean10000 at 8:41 pm (utc) on Jul 3, 2013]
[edit reason] Fixed AutoLinking [/edit]
and so on
If you ask for
http://subdomain.example.com without anything, the url stays the same, but you see http://www.example.com
http://subdomain.example.com/subdomain/index.php
RewriteCond %{REQUEST_URI} ^/(subdomain1)/ [NC]
RewriteRule (.*) http://subdomain1.example.com/$1 [R=301,L]
[edited by: phranque at 7:17 pm (utc) on Jul 4, 2013]
[edit reason] unlinked urls [/edit]
If you ask for http://subdomain.example.com without anything, the url stays the same, but you see http://www.example.com
RewriteRule ^(subdomain1/.*) http://subdomain1.example.com/$1 [R=301,L]
Works the same as the code I am using
I use the subdomain twice because in some cases the name of the subdomain is different from the name of the folder.
RewriteCond %{HTTP:Host} ^((?!www\.)(.+)|(?:www\.)(.+))\.(example\.com)$ [NC]
RewriteCond %{REQUEST_URI} (.+)
RewriteRule .? /%2%3%5 [L]
$SiteNameURL = $_SERVER['HTTP_HOST'];
switch (strtolower($SiteNameURL)) {
case "subdomain.example.com": //MUST BE LOWER CASE
header("Location: http://" . $_SERVER['HTTP_HOST'] . "/subdomain/index.php");
break;
I found an easy way out
header("Location: http://" . $_SERVER['HTTP_HOST'] . "/subdomain/index.php");
DirectoryIndex index.php Maybe not the best solution, but it works.