LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   redirect http to https (https://www.linuxquestions.org/questions/linux-newbie-8/redirect-http-to-https-757459/)

nagavinodh 09-24-2009 06:53 AM

redirect http to https
 
Hi,
how to redirect automatically from http://test.yan.com to https://test.yan.com.
we configured the ssl on test.yan.com in apache.

if https://test.yan.com,it is working.

if http://test.yan.com,it is not working and auotmatically redirected.

how to solve that

bathory 09-24-2009 07:18 AM

You can use mod_rewrite:
Code:

RewriteEngine on
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI}

Regards

nagavinodh 09-24-2009 08:23 AM

Quote:

Originally Posted by bathory (Post 3695425)
You can use mod_rewrite:
Code:

RewriteEngine on
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI}

Regards

thanks for reply.mod-rewrite is not there on httpd.conf.where i have to mention that

bathory 09-24-2009 08:34 AM

In you case, since you want to redirect all the traffic in https, it's better to put it inside the Directory definition of your DocumentRoot. I..e, if you have an entry "DocumentRoot /var/www", then you have to put it inside the <Directory /var/www>...</Directory> part.
But it can go everywhere, even inside a .htaccess.

Regards


All times are GMT -5. The time now is 10:59 AM.