I want to redirect the users of my application to HTTPS protocol when they visit Login page. The URL is of kind:
http://localhost/default/Login
I have written below Rewrite rule in my apache conf file ( Please note that I want to do it from conf file only and not from .htaccess)
RewriteEngine on
RewriteCond %{HTTPS} !=on
RewriteRule ^/Login$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
This redirect is not working and I am not able to find out the reason. Have also tried printing rewrite logs , but not able to debug from that as well.
Please let me know what am i doing wrong.
RewriteCond %{HTTPS} off
RewriteCond %{REQUEST_URI} Login [NC]
RewriteRule $ https://%{HTTP_HOST}%{REQUEST_URI} [L,R]
This rule solved my problem. Found out that ^
was for start of URL.
Try adding the code below to your httpd.conf file.
Redirect permanent / https://localhost/default/Login
See Link for full description
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.