I need to redirect all “http” requests to “https”. I did something like this:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTP:X-Forwarded-Proto} !https
RewriteRule (.*) https://example.com.br/site/$1 [R=301,L]
</IfModule>
It seems work appropriately, but this is not loading files. Files should be opened using the url:
https://example.com.br/site/wp-content/themes/briefing/css/style.css
but instead, the page try to load:
https://example.com.br/site/css/style.css
“https://” does not appear in Browser. I am using WordPress, the site is inside a “site” folder. My big problem is because I have a ajax request and had the following error:
XMLHttpRequest cannot load https://exemple.com.br/site/wp-content/themes/briefing/includes/loopHandler.php?numPosts=3&pageNumber=1. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://example.com.br' is therefore not allowed access.
My htacess file begins with:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /site/
RewriteRule ^index.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /site/index.php [L]
</IfModule>
What should I do?
You need to replace your
RewriteCond
:by the following:
The
HTTP:X-Forwarded-Proto
you currently using only checks if a proxy forwarded non https traffic. This is not really related to your problem. You need a general check if incoming requests are not https requests:%{HTTPS} !on
.You may can try that:
Keep your rules like this:
https://
URLs.