Here are some frequently asked questions about Apache WebServers.
After you add an SSL Certificate to your website, people may still try to connect to it using HTTP, which is considered insecure these days. #BEGIN HTTPS Redirect This essentially says: Note. Thank you Jacob Buller of EcoVillages.CA for your help in debugging this. This can be caused by a number of things, however, if you use more than one “environment” under your registered website name, this solution should fix this for you. Also, if you have recently switched from Plain PermaLinks to %postname% PermaLinks or others, you may run into this problem as well. By “environments”, I mean things like test, devl, next (stage), prod, etc. These are normally called sub-domains. They could also be different language translations. EG. en, fr, es, ru, etc. Regardless, the situation results in too many redirects as WordPress does not automatically redirect to index.php when the URL ends with a directory name with or without a trailing /, resulting in an infinite loop. For example: If you have registered MySite.com, the internet will direct your request to where your main site is located. EG. https://MySite.com. You may have two environments, stage and prod, which is quite common and strongly recommended. Stage is where you make your changes and test them, prod is your environment that the world sees. <?php You can access the other directories using the URL request. EG. https://MySite.com/stage. Generally, this will partially work if you include a page name. EG. https://MySite.com/stage/about_us, however, the directives that WordPress inserts by default, break when no page name is specified. EG. https://MySite.com/stage or https://MySite/stage/ and https://MySite.com/prod or https://MySite.com/prod and since you have the redirect in the home directory, https://MySite.com or https://MySite.com/. # BEGIN Aldersoft Permalink fix and also the following needs to be added to the beginning of your .htaccess in public_html/prod. # BEGIN Aldersoft Permalink fix This essentially says: Note. Thank you Jacob Buller of EcoVillages.CA for your help in debugging this. How do I force all requests to use HTTPS ?
To address this, you can either create a separate directory for “secure” pages or simply redirect pages to always use HTTPS. If you are using an Apache webserver.
Add the following to the beginning of your .htaccess file.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
</IfModule>
#END HTTPS Redirect
Note. You can also redirect with just R or R=302. The 302 says this is a temporary redirect.
Often webservers will remember permanent redirects and will cache them for speed.Why do I keep getting “too many redirects” when I retrieve the Home Page, but not any other page ?
Hence you have two WordPress installations: https://MySite.com/stage and https://MySite/prod. You normally want prod to be your “goto” WordPress site, so you put a redirect into the MySite.com “home” directory to send people automatically to prod. For example, you would create an index.php file in your home directory which contains the following redirect. (Note. The home directory is usually public_html in your cPanel File Manager.)
/* Redirect to MySite.com/prod with a permanent redirect */
header( ‘Location: https://MySite.com/prod/’, TRUE, 301 );
?>
Using our example, you need to add the following to the beginning of the .htaccess file in public_html/stage.
# Fix WordPress Permalink bug for URLS, not including index.php
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule .* – [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteRule ^$ https://%{HTTP_HOST}/stage/index.php [R,L]
RewriteRule ^(.*)%{HTTP_HOST}$ $1%{HTTP_HOST}/stage/index.php [R,L]
RewriteRule ^(.*)%{HTTP_HOST}/$ $1%{HTTP_HOST}/stage/index.php [R,L]
</IfModule>
#END Aldersoft Permalink Fix
# Fix WordPress Permalink bug for URLS, not including index.php
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule .* – [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteRule ^$ https://%{HTTP_HOST}/prod/index.php [R,L]
RewriteRule ^(.*)%{HTTP_HOST}$ $1%{HTTP_HOST}/prod/index.php [R,L]
RewriteRule ^(.*)%{HTTP_HOST}/$ $1%{HTTP_HOST}/prod/index.php [R,L]
</IfModule>
#END Aldersoft Permalink Fix
Then rebuild the URL to point to https://MySite.com/prod/index.php
EG. https://MySite.com/prod will have %{HTTP_HOST} of “MySite.com”
This will be rebuilt as https://MySite.com/prod/index.php
Lastly [R,L], says redirect (302) to the new URL, leave .htaccess, and start again.
Then rebuild the URL to point to https://mysite.com/prod/index.php
Lastly [R,L], says redirect (302) to the new URL, leave .htaccess, and start again.
Then rebuild the URL to point to https://MySite.com/prod/index.php
Lastly [R,L], says redirect (302) to the new URL, leave .htaccess, and start again.