Forum Moderators: phranque
RewriteCond %{HTTP_HOST} demo\.za\.org
RewriteRule (.*) http://www.demo.com/sub$1 [R=301,L]
RewriteCond %{HTTP_HOST} !\b(test1|test2)\.(za.net|za.org|co.za|com|net)$
RewriteCond %{REQUEST_URI} !^/(folder|phpinfo\.php|google1234\.html|pinterest-1234\.html)
RewriteCond %{HTTP_HOST} !^(.*)\.(.*)\.(.*) [NC]
RewriteRule (.*)$ http://blog.example.com/$1 [R=301,L] Is it possible to create "subdomains" without actually creating matching folders?
RewriteRule (.*)$ http://blog.example.com/$1 [R=301,L]
RewriteCond %{HTTP_HOST} !blog\.example\.za
to prevent infinite loops. RewriteCond %{HTTP_HOST} !^(.*)\.(.*)\.(.*) [NC] <?php
# Example subdomain requested is: the-page.example.com
# Remove .example.com to find the page name
$check_for_page=str_replace('.example.com','',$_SERVER['HTTP_HOST']);
# Request http://blog.example.com/some/stuff/here/the-page.ext
$show_page=file_get_contents('http://blog.example.com/some/stuff/here/'.$check_for_page.'.ext');
# If it's really a page show it to the visitor
if(strpos($http_response_header[0],'200')!==FALSE) {
echo $show_page;
exit;
}
# If it's not a page, redirect to blog.example.com
else {
header('Location: http://blog.example.com/',TRUE,301);
exit;
}
?>