I'm currently building a Wordpress powered website that is distributed across three servers, two of which are used to server the front end (Live), and another of which is used for the admin (Admin).
The codebase on all three servers is exactly the same, and comes from the same subversion repository, we need to keep it this way so that when we commit a change it gets pushed to all three servers.
For this reason, I need to have one .htaccess file that can do multiple functions, but to specific environments.
The URL structure is currently:
- Live -http://www.{SITE_NAME}.co.uk
- Admin -http://admin.{SITE_NAME}.co.uk
I need to achieve the following three conditions from one single .htaccess file.
I need to force non www urls to www urls, only on the Live environmemt, the Admin environment needs to remain untouched, i.e -http://admin.{SITE_NAME}.co.uk.
All requests to -http://admin.{SITE_NAME}.co.uk get redirected to -http://admin.{SITE_NAME}.co.uk/wp-admin
Any requests to (Live) -http://www.{SITE_NAME}.co.uk/wp-admin and -http://www.{SITE_NAME}.co.uk/wp-content get redirected back to -http://www.{SITE_NAME}.co.uk, but any files that exist can be accessed, such as images/theme files etc.
I currently have the following rules, but at present I need to remove step 1 above on the admin box, as any requests to -http://admin.{SITE_NAME}.co.uk/wp-admin get redirected to -http://www.{SITE_NAME}.co.uk/wp-admin
Admin rewrite
RewriteEngine On RewriteCond %{HTTP_HOST} admin.{SITE_NAME}.co.uk [NC] RewriteRule ^index.php$ wp-admin [NC]
Non www rewrite
RewriteCond %{HTTP_HOST} !^www.{SITE_NAME}.co.uk RewriteRule (.*) http://www.{SITE_NAME}.co.uk/$1 [R=301,L]
Any help would be greatly appreciated!