Apr 25, 2013 - Searched for apache redirect http to https and landed here. A permanent redirect in Apache using status code 301. An easy HTTP to HTTPS redirect in Apache is often better accomplished in the Apache configuration, if you have access to the configuration files, rather than by using a.htaccess file. A rewrite is often a relatively resource expensive operation.
Trying to setup automatic redirection from http to https
I have tried adding the following to my httpd.conf but it didn't work
Any ideas?
DeanoDeano
10 Answers
I have actually followed this example and it worked for me :)
Then do:
/etc/init.d/httpd restart
DeanoDeano
or
IdemeNaHavajIdemeNaHavaj
Searched for apache redirect http to https and landed here. This is what i did on ubuntu:
1) Enable modules
2) Edit your site config
Edit file
Content should be:
Note that the SSL module requires certificate. you will need to specify existing one (if you bought one) or to generate a self-signed certificate by yourself.
3) Restart apache2
Jossef HarushJossef Harush
Actually, your topic is belongs on https://serverfault.com/ but you can still try to check these .htaccess directives:
Community♦
5ervant5ervant
Using mod_rewrite is not the recommended way instead use virtual host and redirect.
In case, if you are inclined to do using mod_rewrite:
Reference: Httpd Wiki - RewriteHTTPToHTTPS
If you are looking for a 301 Permanent Redirect, then redirect flag should be as,
so the RewriteRule will be like,
VincyVincy
If you have Apache2.4 check 000-default.conf - remove DocumentRoot and add
indifferenceindifference
Server version: Apache/2.4.29 (Ubuntu)
After long search on the web and in the official documentation of apache, the only solution that worked for me came from /usr/share/doc/apache2/README.Debian.gz
In the file /etc/apache2/sites-available/000-default.conf add the
Redirect '/' 'https://sub.domain.com/'
That's it.
P.S: If you want to read the manual without extracting:
DimiDakDimiDak
FintFint
user7817632user7817632
Please try this one in apache Virtualhosting configurationand then reload apache service
MD IRFANMD IRFAN
Not the answer you're looking for? Browse other questions tagged linuxapachewebserver or ask your own question.