开发者

How To Redirect URL To Another URL

Let say i've websi开发者_开发知识库te of url http://-*-my-site-url-*-.com and i've installed SSL Certificate so i want using .htaccess to automatically redirect any visitor

hit http://-*-my-site-url-*-.com To https://-*-my-site-url-*-.com (Notice https://)

what is the .htaccess code should i add and will it change the sub-pages too OR only main page .

Thanks


Simple and Straight forward code will work for all the url.

RewriteEngine on
RewriteCond %{SERVER_PORT} !^443$
RewriteRule ^.*$ https://%{SERVER_NAME}%{REQUEST_URI} [L,R]


You can add the following lines to your htaccess file :

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

The first line tells Apache we are going to use mod_rewrite. The second line checks to see if it is using ssl. If that second line matches then the third uses variables (better than using -*-my-site-url-*-.com) to redirect the user to the SSL version of your URL.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜