Skip to content

Instantly share code, notes, and snippets.

@timkinnane
Last active August 29, 2015 14:06
Show Gist options
  • Save timkinnane/2b6ad0be9ab20579ad14 to your computer and use it in GitHub Desktop.
Save timkinnane/2b6ad0be9ab20579ad14 to your computer and use it in GitHub Desktop.
htaccess for two Wordpress installs in side by side subfolders, one resolving to primary domain, one to subdomain.
## Example DOMAIN.TLD serves MAIN folder
## SUB folder served from SUB.DOMAIN.TLD
## --- public_html/ .htaccess --- ##
RewriteEngine On
RewriteCond %{HTTP_HOST} ^(www.)?DOMAIN.TLD/$
RewriteRule ^$ /MAIN/ [L]
# Remove WWW (optional)
RewriteCond %{HTTP_HOST} ^www.DOMAIN.TLD$ [NC]
RewriteRule ^(.*)$ http://DOMAIN.TLD/$1 [L]
# Redirect to folder
RewriteCond %{HTTP_HOST} ^(www.)?DOMAIN.TLD$
RewriteCond %{REQUEST_URI} !^/MAIN/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /MAIN/$1
## --- MAIN folder .htaccess --- ##
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /MAIN/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /MAIN/index.php [L]
</IfModule>
## --- SUB folder .htaccess = WP default --- ##
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment