jeudi 26 mars 2015

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://ift.tt/1IpFWfw [R=301,L]


This is so that the forums that exist at http://ift.tt/1jBarQy are accessed at http://ift.tt/11ksZ6O


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://ift.tt/1IpFWfw [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!





Aucun commentaire:

Enregistrer un commentaire