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?
/wp1
, the htaccess directives are the usual" - Although the "problem" with the "usual" directives in.htaccess
is that those directives are intended to work with a site installed in the root, not a subdirectory. "...and index.php in root loads the necessarywp1/wp-blog-header.php
" - Why are you doing it that way?wp2
subdomain to point directly to the/wp2
subdirectory, instead of the document root of the main site (which I assume is where it is pointing to now)? Then you wouldn't have to do anything. (I assume/wp1
features in the URLs for the live site?)