I am using a single database for two different sites. One is sitejury and the other is cdn1.sitejury. I'm trying to serve my files using the subdomain.
Previously I used simple https Rewrite for my domain. but now with my increasing need, it has become complex for me to set up.
I need to redirect both www.domain or domain to
Redirect all version of cdn.domain to SSL-https//:domain version except (option- 3)
Subfolder "wp-content" and "wp-includes" stay on both the domain domain and CDN domain with https. I only need these two files to redirect to their https version.
I am using a single database for two different sites. One is sitejury and the other is cdn1.sitejury. I'm trying to serve my files using the subdomain.
Previously I used simple https Rewrite for my domain. but now with my increasing need, it has become complex for me to set up.
I need to redirect both www.domain or domain to https://domain
Redirect all version of cdn.domain to SSL-https//:domain version except (option- 3)
Subfolder "wp-content" and "wp-includes" stay on both the domain domain and CDN domain with https. I only need these two files to redirect to their https version.
- When you say a single database for two sites, is this 2 independent installs? Or is this a multisite install? Keep in mind that redirecting non-HTTPS to HTTPS isn't a WOrdPress question but an Apache question – Tom J Nowell ♦ Commented Jul 19, 2019 at 12:36
- not independent, no multisite but a single same database. I created the subdomain directly on the main domain database and changed CNAME. everything exists on both sites. I need to limit access with rewrites. – Bikram Commented Jul 19, 2019 at 12:39
- Can you clarify further? If they both use the same install of WordPress and the same database, but it isn't a multisite install, are they not the same website, how does that work? I don't understand, and I don't know what you mean by "I created the subdomain directly on the main domain database", that sentence doesn't make sense, can you word it differently ( be very precise with the terms you use ) – Tom J Nowell ♦ Commented Jul 19, 2019 at 12:44
- Could it be that you actually have a single site that has 2 URLs? – Tom J Nowell ♦ Commented Jul 19, 2019 at 12:45
- I had site:domain at folder:domain first. Next, I created a subdomain cdn.domain directly on the folder: domain but not on the folder: cdn.domain. I just did it so that both site URLs get the same content from the same files. I need the CDN subdomain to serve the spesific folders and redirect all others to the main domain – Bikram Commented Jul 19, 2019 at 12:51
1 Answer
Reset to default 0I'm currently using this-
# TN - BEGIN https to https
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteCond %{HTTP_HOST} ^scorewheel\$ [OR]
RewriteCond %{HTTP_HOST} ^www\.scorewheel\$
RewriteRule .* https://scorewheel%{REQUEST_URI} [R=301,L]
</IfModule>
# TN - END http to https
# TN - Begin cdn redirection
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{HTTP_HOST} ^cdn.scorewheel\$ [OR]
RewriteCond %{HTTP_HOST} ^www\.cdn.scorewheel\$
RewriteCond %{REQUEST_URI} !^/wp-content/
RewriteCond %{REQUEST_URI} !^/wp-includes/
RewriteRule (.*) https://scorewheel%{REQUEST_URI} [R=301,L]
</IfModule>
# TN - End cdn redirection
# TN - Begin cdn https
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule ^/?wp-content/(.*) https://cdn.scorewheel/wp-content/$1 [R=301,L]
RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule ^/?wp-includes/(.*) https://cdn.scorewheel/wp-includes/$1 [R=301,L]
</IfModule>
# TN - End cdn https