Redirect subdirectory to subdomain

Just a quick note, lest I forget this. To redirect a subdirectory to a subdomain using .htaccess, use the following:

<ifmodule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^subdirectory(.*)$ http://subdomain.domain.tld$1 [R=301,L]
</ifmodule>

(Note the 301 permanent redirect.) The regular expression is greedy, but it takes care of the trailing slashes — just in case. *shrugs*

Comments

Popular posts from this blog

Pull files off Android phone