- Enable Https Apache2
- Apache Forward Http To Https
- Apache2 Redirect Http To Https Ubuntu
- Apache2 Https Configuration
Really consider doing something the reverse: redirect HTTP to HTTPS (notably your main portal or static public pages that don't need private data/sessions/cookies) and use HTTPS for everelse. If you ever need to get from HTTPS to HTTP, use standard links (in distinct requests) – verdyp Feb 17 '19 at 12:20. I think last time this happened to me it may have been something weird like NameVirtualHost.:80/NameVirtualHost.:443 and/or Listen 80/Listen 443 were somewhere other than ports.conf for apache2. Here is what I have in VirtualHost to redirect to https for all pages except for press (had a video that couldn't be served https so had to redirect back to http otherwise people would get ugly. Force HTTPS redirection with Apache NOTE: We are in the process of modifying the file structure and configuration for many Bitnami stacks. On account of these changes, the file paths stated in this guide may change depending on whether your Bitnami stack uses native Linux system packages (Approach A), or if it is a self-contained installation.
19 hours ago Apache httpd reverse proxy returns SSLERRORRXRECORDTOOLONG when HTTP redirects to HTTPS 0 Redirect on the same port from http to https with nginx reverse proxy.

Apache’s mod_rewrite makes it easy to require SSL to be used on your site and to gently redirect users who forget to add the https when typing the URL. Using Apache to redirect http to https will make sure that your site (or a part of it) will only be accessed by your customers using SSL. This is better than using SSLRequireSSL because users often forget to type in the https and will be automatically redirected.
Before you can set up an Apache redirect from http to https, you will need to do the following:
- Make sure your SSL certificate is successfully installed so you can access https://www.yoursite.com (for more information see our Apache SSL Installation instructions)
- Make sure mod_rewrite is enabled in Apache
Now you just need to edit your httpd.conf file or the file where your virtual host is specified and add these lines to redirect http to https:
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{SERVER_NAME}/$1 [R,L]

In many cases, you can also just add those lines to a file named .htaccess in the folder that you want to redirect http to https.
Now, when a visitor types http://www.yoursite.com/mypage.htm the server will automatically redirect http to https so that they go to https://www.yoursite.com/mypage.htm
Note: You can also redirect a single page from http to http in Apache by using this in your configuration file or .htaccess file:
RewriteEngine On
RewriteRule ^apache-redirect-http-to-https.html$ https://www.yoursite.com/apache-redirect-http-to-https.html [R=301,L]
Originally posted on Sat Feb 20, 2010
In the old days, website communication was hardly secured, and all websites’ URLs started with www. Nowadays most websites are secured using a SSL certificate, and most also dropped the www from their URL.
All good and well, but how can you ensure old links do not result in a 404 error?
In this – short – article, I show you how you make sure all old links are redirected correctly when you secure your site or want to drop the www from your site’s URL.
Redirecting your links from http to https
Sites that have existed for more than a couple of years will mostly have run some time without SSL security. Their default URL started with http://. Now these sites have installed SSL security, so now their default URL starts with https://.
However, there are a lot of links out there that point to that site still using http://, and many people still use http:// when they type in the URL. These links all need to redirect to the new URL for the same page.
You can create redirects for each page separately, but it is a lot easier to have a rule in you .htaccess file that does it for you automatically.
Note: do not change ANYTHING in your .htaccess file without having a working copy of the file on your desktop. Any typo in the file WILL bring your site down.
The code below takes any http link and redirects it to its exact equivalent starting with https://.
Warning: when you use this code on a WordPress site and you have a plugin that redirects http to https, either turn off that feature or don’t use this code. It will create a loop of redirects, and you site will be down!
Redirecting your links from https to http
Even though I cannot think of a situation where you would want to do the reverse, here is the code to redirects
an https link and redirects it to its exact equivalent starting with http://.
Redirecting your links from www to non-www
When websites were a new thing, all URLs started with www, which stands for World Wide Web. Nowadays, most websites drop the www and just use the shorter URL.
To redirect all incoming links using www to their equivalents without www, you can use this code in your .htaccess file:
Redirecting your links from non-www to www
Of course, there will be websites that choose to have www in their URL.
Enable Https Apache2
To redirect all incoming links using without www to their equivalents that include www, use this code:
Redirecting your links from http to https and from www to non-www
The code snippets above do only one thing – and do it well – but you can also combine the code into one combined redirect.
The code below redirects any http link to its exact equivalent starting with https AND in the process redirects any www link to its equivalent without www in the URL:
Redirecting your links from http to https and from non-www to www
Apache Forward Http To Https
And to redirect any http link to its equivalent starting with https AND redirect any non-www link to its equivalent with www in the URL, use this code:
Apache2 Redirect Http To Https Ubuntu
The snippets above are very handy to ensure a site’s URLs all keep working, but there are many more handy snippets you can use in your .htaccess file to make your life easier. Check out the many excellent snippets in the resources. Just make sure you have a working copy of your .htaccess file ready in case things go sour.
How do you solve redirection issues? Do you use code snippets, or do you make use of plugins? Please share in the comments section.
Resources
Apache2 Https Configuration
Apache redirect www to non-www and HTTP to HTTPS (Simon Carletti)
23 Awesome .htaccess redirection from (www to Non-www) AND (Non-www to www) (2daygeek)
.htaccess Snippets (GitHub)
