Apache - Ubuntu Server - Redirect HTTP to HTTPS - apache

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?

Related

Change URL access of API via htaccess

In my PC, I have express API running with PM2 on port 3000 and use Apache as web service on regular port (80) which can be accessed via http://localhost via browser.
On documentroot folder, i added htaccess file with following code :
DirectoryIndex disabled
RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ http://%{HTTP_HOST}:3000/$1 [P,L]
RewriteRule ^$ http://%{HTTP_HOST}:3000/ [P,L]
So when I access : http://localhost, that show the root api endpoint becase that rewrite rule.
Is it safe or what the impact will i get if I did that?

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}

kohana site on localhost is not working with https://

I have a website written with kohana. I want to test it if its working with ssl. I have ssl module installed (ubuntu default ssl configuration). The problem is: all my websites using kohana on localhost (apache) not working with https:// (only main pages are working for example: "https:localhost/kohanasite" is working, but if i give controller and action it is not working, but if i ad index.php before controler and action it is working again). Other websites (not written with kohana) are working properly. My htaccess is as follows:
RewriteEngine On
RewriteBase /sitename/
Order Deny,Allow
Deny From All
RewriteRule ^(?:application|modules|system)\b.* index.php/$0 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php/$0 [PT]
php_value allow_url_fopen on
php_value allow_url_include 1
Plese help.
You need to create a new Apache configuration for the https sites too. Enable the module is not enough. How do I allow HTTPS for Apache on localhost?

Redirect from https to http url stored from google

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}

Rewrite from https to http

I have 5 sites on one apache server. One of the sites is with SSL. So when the other sites are accessed with https then they are redirected to the SSL site which is incorrect.
E.g.
https://x.com (with SSL)
http://y.com (normal site no SSL)
If I access https://y.com then I get the content from x.com. How can I fix so https://y.com just gets rewritten to http://y.com?
In your .htaccess put:
RewriteCond %{HTTPS} on [NC]
RewriteRule ^(.*)$ http://y.com/$1 [R=301,L]
You can define it in apache config file. You must add a rule to connection incoming from https port.
If you are using linux, propably you have this config in /etc/apache2/sites-available/default-ssl.
If you don't have this file you must searching https virtualhost:
<IfModule mod_ssl.c>
<VirtualHost _default_:443>