Use subdomain for certain urls
I have the following rules in my .htaccess file on a WordPress (single installation):
# REWRITE FORUMS DOMAIN TO FOLDER
RewriteCond %{HTTP_HOST} ^forums\.example\.com$
RewriteRule !^forums/? forums%{REQUEST_URI} [NC,L]
# REWRITE FORUMS FOLDER TO SUBDOMAIN
RewriteCond %{THE_REQUEST} \s/forums/([^\s]*) [NC]
RewriteRule ^ http://forums.example.com/%1 [R=301,L]
This is so that the forums that exist at http://example.com/forums
are accessed at http://forums.example.com/
However the server just blows up with a 500 server error...
Any ideas on how to do this? These rules work perfectly when used on non-wordpress sites... The second rewrite rules successfully send /forums to the sub domain but the subdomain doesn't seem to be able to pass the data into WordPress correctly.'
The whole htaccess file looks like:
IfModule mod_rewrite.c
RewriteEngine On
RewriteBase /
# REWRITE FORUMS DOMAIN TO FOLDER
RewriteCond %{HTTP_HOST} ^forums\.example\.com$
RewriteRule !^forums/? forums%{REQUEST_URI} [NC,L]
# REWRITE FORUMS FOLDER TO SUBDOMAIN
RewriteCond %{THE_REQUEST} \s/forums/([^\s]*) [NC]
RewriteRule ^ http://forums.example.com/%1 [R=301,L]
# BEGIN WordPress
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
# END WordPress
/IfModule
The reason that the WordPress rules are after the forums rules are because if I put them after then they are never hit!
Topic apache url-rewriting htaccess Wordpress
Category Web