Reputation: 132
i have installed ssl on my site using following code in htaccess:
RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://www.example.com/$1 [R,L]
now when i check http://www.redirect-checker.org it shows 302 bad idea.. Please help me changing it to 301.
I have tried this code before:
RewriteEngine on
RewriteCond %{HTTP_HOST} ^yoursite.com [NC,OR]
RewriteCond %{HTTP_HOST} ^www.yoursite.com [NC]
RewriteRule ^(.*)$ https://www.yoursite.com/$1 [L,R=301,NC]
but it dint work... it showed error site isnt redirecting properly.. so how to solve this problem????
Upvotes: 0
Views: 1712
Reputation: 18671
You can use that:
RewriteEngine on
RewriteCond %{HTTPS} off
RewriteRule ^ https://www.example.com%{REQUEST_URI} [NE,R=301,L]
Use of the [R] flag causes a HTTP redirect to be issued to the browser, with a 302 status code being used by default if none is specified.
Upvotes: 2