HowtoForge Forums | HowtoForge - Linux Howtos and Tutorials

HowtoForge Forums | HowtoForge - Linux Howtos and Tutorials (http://www.howtoforge.com/forums/index.php)
-   Installation/Configuration (http://www.howtoforge.com/forums/forumdisplay.php?f=16)
-   -   Redirect HTTPS to HTTP (http://www.howtoforge.com/forums/showthread.php?t=35199)

Jürgen 20th May 2009 00:34

Redirect HTTPS to HTTP
 
Hello,

I have a lot of domains running. All of these don't use any SSL certificate. So I would like to redirect all requests on https to the http page instead of showing an error.

Is that possible?

Thanks a lot

Ben 20th May 2009 09:35

Well I am using mod_rewrite to redirect all http for a host to https, so this should work vice versa:

Code for http -> https
Quote:

RewriteEngine On
RewriteCond %{SERVER_PORT} !^443$
RewriteRule ^.*$ https://%{SERVER_NAME}%{REQUEST_URI} [L,R]
Should do for https to http
Quote:

RewriteEngine On
RewriteCond %{SERVER_PORT} !^80$
RewriteRule ^.*$ http://%{SERVER_NAME}%{REQUEST_URI} [L,R]
But keep in mind, that anyway all users will get the cert warning if it not fits a known CA, is invalid, does not fit the hostname etc. anyway. Only _after_ establishing the ssl conn the rewrite request will be processed.

Also this config needs to be done for every user (afaik you can not set those rewrite rules for all vhosts from a global base?!)

n0fx 13th March 2012 01:52

Quote:

Originally Posted by Ben (Post 189271)
Well I am using mod_rewrite to redirect all http for a host to https, so this should work vice versa:

Code for http -> https


Should do for https to http


But keep in mind, that anyway all users will get the cert warning if it not fits a known CA, is invalid, does not fit the hostname etc. anyway. Only _after_ establishing the ssl conn the rewrite request will be processed.

Also this config needs to be done for every user (afaik you can not set those rewrite rules for all vhosts from a global base?!)


For the code above, do I edit it in the .htaccess file in the root to have my site go from https:// to http://?

till 13th March 2012 11:13

Edit or add the .htaccess file which is in the web directory.

n0fx 13th March 2012 19:47

This is a weird issue with my server http crashes
 
Quote:

Originally Posted by till (Post 275375)
Edit or add the .htaccess file which is in the web directory.

I tried editing the /var/www/web1/.htaccess file but it doesn't work. I also found another directory that had the .htaccess file which was /var/www/www.mywebsite.com/web/.htaccess. I edited the /var/www/web1/.htaccess file first and I found out the file in /var/www/web/www.mywebsite.com/ also got modified with the same information?

When I added the code, it doesn't forward the user to the http:// part of the website. it would not load at all, it just times out. I just commented out the modification in the /var/www/web1/.htaccess file, since it didn't work.

I'm having this weird issue, when a user tries to load the https:// portion of the site (it's not setup with SSL at all, I had the user with SSL checked under their account in ISPconfig but never setup the SSL for it, there is no certificate installed), it crashes the http:// part of the site. What I mean is that I can't load the http:// part of the site anymore, it just times out on the browser.

The only way to get it back up and running is to manually reboot the server. I tried to restart the apache service with /etc/init.d/apache restart but it doesn't fix the problem. I can ping the external dns/ip name and it responds back with a ping but just doesn't answer the normal http:// requests.

My server is configured with two network cards, one has an internal IP address and the other is directly connected on the net (external ip). When the http:// part of my site crashes/stops responding, I can still access the ISPconfig webpage and when I type in the internal ip address in the browser, it loads up the message that says that it's a shared IP address.

Does anyone know why when sometime loads the https:// part of the site, it causes my non ssl http:// to stop loading?


All times are GMT +2. The time now is 06:47.

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.