Home › Forums › BulletProof Security Pro › WordPress SSL htaccess code – Rewrite SSL, RewriteCond Server Port
Tagged: htaccess SSL, HTTPS, Rewrite SSL, RewriteCond, SSL, SSL Vhost, WordPress SSL, WordPress SSL htaccess code
- This topic has 124 replies, 23 voices, and was last updated 3 months ago by
AITpro Admin.
-
AuthorPosts
-
verysingh
ParticipantSo since it is free and easy to get an SSL Certificate then that is the best route to go instead of trying to do some sort of 3rd party logo image hosting.
jose sally
ParticipantThanks, i’ll try it on my site
nehakakar kakar
ParticipantTo redirect your WordPress website to SSL (HTTPS) using the .htaccess file and to include RewriteCond for server port, you can use the following code:
RewriteEngine On # Redirect to HTTPS RewriteCond %{HTTPS} off RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301] # Redirect to non-www RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC] RewriteRule ^(.*)$ https://%1/$1 [R=301,L] # RewriteCond for server port (example: redirect from port 80 to 443) RewriteCond %{SERVER_PORT} 80 RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
Make sure to place this code in the .htaccess file in the root directory of your WordPress installation.
Here’s what the code does:
- The first block redirects all HTTP requests to HTTPS. If the request is made over HTTP (port 80), it redirects to the same URL using HTTPS (port 443).
- The second block removes the ‘www’ from the URL. If the request includes ‘www’ in the domain, it redirects to the same URL without ‘www’.
- The third block is an additional condition using RewriteCond for the server port. In this example, it redirects requests made on port 80 to HTTPS (port 443). Adjust the server port numbers as per your specific requirements.
Please note that before making any changes to your .htaccess file, it’s always a good practice to create a backup of the original file. Additionally, if you have any existing code in your .htaccess file, make sure to place this code in the appropriate location, typically after the
RewriteEngine On
line.sebastian
ParticipantHi,
I have a problem with my htaccess codein the custom area, before I installed BPS ( pro) everything was still working fine :)), I’ve been around for a long time, but I’ve never really warmed up to regular expressions, htaccess etc. It would be great if one of you could tell me where to insert the code so that it works again.
Maybe not useless to understand, if someone enters website.org/vibifx, he should be redirected to:
http://www.website.org/home/found/?vibifxI just can’t get it to work…
my .htaccess:
RewriteEngine On RewriteCond %{HTTP_HOST} ^website\.org [NC] RewriteCond %{HTTP_HOST} !^www\. [NC] RewriteCond %{REQUEST_URI} ^/([a-zA-Z0-9]+)$ RewriteCond %1 !=home RewriteRule ^(.*)$ http://www.website.org/home/found/?foundid=%1 [R=301,L]
Hope you understand my problem & thanks in advance
Sebastian
AITpro Admin
KeymasterI don’t have enough info to help you. I tried going to the destination redirect URL and it goes to the same generic hosting page. Explain in detail what you are trying to do.
-
AuthorPosts
- You must be logged in to reply to this topic.