Forcing HTTPS over HTTP

后端 未结 4 872
广开言路
广开言路 2021-01-23 21:06

So I want to force the user to access the https version of my page rather than the http. And according to this post all I have to do is this:

RewriteEngine On 
R         


        
4条回答
  •  故里飘歌
    2021-01-23 21:37

    This is a not-so-good method of going about this, especially if you have access to httpd.conf. The better method is to create TWO virtual hosts. One for your standard port 80 stuff, which simply has an unconditional redirect to the SSL version, e.g. in pseudo-ish .conf talk:

    
       RedirectPermanent / https://example.com
       DocumentRoot /some/fake/path
    
    
    
       normal site stuff here...
    
    

    This has the advantage of leaving the redirect viable even if a config messup disables .htaccess files, plus serving up bogus/non-existent content if SSL dies for whatever reason.

提交回复
热议问题