Redirect from https to http url stored from google - apache

in a search from google , i found my domain url with https and not http .
For example : https://xxxx.com/yyyy/zzzz and not http://xxxx.com/yyyy/zzzz
It's possible redirect from https to http for the domain xxxx.com ?
I use centos and apache web server
On the same server, i have a certificate https that respond to https://zzzz.com
Thanks
Carlo

This will work with mod_rewrite on. Put this code in .htaccess file at root of the site.
RewriteEngine On
RewriteCond %{HTTPS} on
RewriteRule (.*) http://%{HTTP_HOST}%{REQUEST_URI}

Related

Apach redirecting https 443 to https with custom port like 3128

I am using Apache web server in front of Squid proxy server on the same machine, and got SSL certificate from Letsencrypt and Apache server now is trusted green site.
I changed the htaccess file to suit my needs to reach Squid server behined Apache in two cases with https or without it . So my htaccess file as following:
RewriteEngine On
# if not https Redirect all requests to Squid except for Let's Encrypt's ACME Challenge verification
RewriteCond %{HTTPS} off [NC]
RewriteCond %{REQUEST_URI} !^/\.well\-known/acme\-challenge/ [NC]
RewriteRule ^(.*) http://backend.squid.server:3128/$1 [R=301,L]
# if https on Redirect all requests to Squid except for Let's Encrypt's ACME Challenge verification
RewriteCond %{HTTPS} on [NC]
RewriteCond %{REQUEST_URI} !^/\.well\-known/acme\-challenge/ [NC]
RewriteRule ^(.*) https://backend.squid.server:3128/$1 [R=301,L]
The first part is redirecting well with no problems and I got the respnse from squid server.
but when we send the same request but with https I got the following error
An error occurred during a connection to backend.squid.server:3128.
SSL received a record that exceeded the maximum permissible length.
Error code: SSL_ERROR_RX_RECORD_TOO_LONG .
what I have on Squid.conf if that may help:
https_port 3128 cert=/etc/letsencrypt/live/mysite.tld/fullchain.pem key=/etc/letsencrypt/live/mysite.tld/privkey.pem
http_port 3128 act-as-origin name=server accel vhost
I think the problem in redirecting from https 443 to https with a custom port.
If anyone has dealt with such an issue Please tell me where is the problem ? what is the right syntax for this in htaccess file

Apache - Ubuntu Server - Redirect HTTP to HTTPS

I am trying to redirect all http to https.
I have added a .htaccess file to my root folder var/www/html/ using:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
</IfModule>
However, this code is not working and the page still showing http connection.
My web site is working fine using https. How can redirect my site to ssl connection? Do I have to restart apache?

HTTPS redirection on AWS ELB

We have web servers running Apache behind an AWS ELB. I have setup the ELB to accept HTTPS connections, and send the requests over HTTP to the webservers. This works fine.
I have also redirected all the requests to ELB from HTTP to HTTPS using HTTP:X-Forwarded-Proto.
I have added the below virtualhost section to my httpd.conf file and restarted Apache. This setup is redirecting HTTP requests to HTTPS but it is landing on the Apache home page instead of the expected site.
ServerName www.myexample.com
RewriteEngine On
RewriteCond %{HTTP:X-Forwarded-Proto} !https
RewriteRule !/index.html https://%{SERVER_NAME}/%{REQUEST_URI} [R=301,L]
The configuration seems to be simple and straightforward but not working.
Please let me know what is wrong in the above setup and why is it landing on the Apache home page.
You should escape the . in your rewrite rule. Change your Rewrite to be:
RewriteRule "!/index\.html" https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
Also, as in the comment to your OP Remove the slash between %{HTTP_HOST}%{REQUEST_URI}

force https on login

I'm trying to force https on the login page with 3.0.13-PL1. I set Server protocol to: https:// but that only changes http:// to https:// affects after the login. I do not want to use mod_rewrite on my server.
Apache
If you are admin Redirect Request to SSL
But I think you aren't:
Apache Redirect HTTP to HTTPS using mod_rewrite
.htaccess
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}

Redirect non https domains to http

I have around 6-7 DOMAINS hosted on linode server where apache is a webserver. One domain is ssl configured and other runs on http only.
Suppose https://www.example.com is ssl configured .
others are
http://www.example1.com
http://www.example2.com
http://www.example3.com
http://www.example4.com
What would be the dynamic rule if someone put https://www.example1.com or others get redirect to http://www.example1.com and so on
like in virtalhost setting for https something like
<If "%{HTTP_HOST} != 'example.com'">
Redirect permanent / http://%{HTTP_HOST}/
</If>
above written hack doesn't work . any help?
You can use this code in your DOCUMENT_ROOT/.htaccess file:
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\.example1\.com$ [NC]
RewriteRule ^ http://www.example1.com%{REQUEST_URI} [NE,R=301,L]