Redirect subdomain to hidden folder using mod_rewrite
Posted
by radious
on Server Fault
See other posts from Server Fault
or by radious
Published on 2009-12-18T17:16:12Z
Indexed on
2010/03/26
19:03 UTC
Read the original article
Hit count: 347
mod-rewrite
|subdomain
Hello! I want to keep my blog in subfolder domain_com/htdocs/blog
and access it using blog.domain.com. I can obtain it using apache's mod_rewrite:
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^blog\.domain\.com
RewriteCond %{HTTP_HOST} !^/blog
RewriteRule ^(.*)$ /blog/$1 [L]
But I also want to redirect hxxp://domain.com/blog to hxxp://blog.domain.com (simply because I want to hide it from users). Simple redirection like:
RewriteCond %{HTTP_HOST} ^wojtyniak\.com$
RewriteRule %{REQUEST_URI} ^/foo
RewriteRule ^(.*)$ http://foo.wojtyniak.com [L,R=301]
causes redirection loop. Is there any way to make such a redirection without loop? Big thanks!
PS. Sorry for those hxxp thing, but serverfault thinks these are link and doesn't allow me to post more than one.
© Server Fault or respective owner