htaccess, site and staging in subdirectories
I have the following task and as it is a little different from most setups, I couldn't find any hints that solved my problem.
WordPress for the live site was installed into a subfolder /wp1
, the .htaccess
directives are a rewrite to www and https followed by the usual WP directives:
IfModule mod_rewrite.c
RewriteEngine On
# rewrite any request to the certified domain to use www
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
# rewrite to HTTPS
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
/IfModule
IfModule mod_rewrite.c
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
/IfModule
and index.php
in the root loads the necessary wp1/wp-blog-header.php
.
Now I need to set up a staging environment in /wp2
with wp2
as the subdomain. The subdomain does not have a SSL-certificate (but I could easily get one). I tried several modifications in order to redirect the subdomain to the staging site without https, but all I got so far was errors.
Although I am not that familiar with .htaccess
, I think the first problem is the wildcard redirect to www. The second obstacle is the redirect to https. I need them both for production.
Is there a way to skip those rules in case the subdomain is addressed?
Or in general, how would you go about that?