htaccess, Redirect all requests to https://

后端 未结 2 1819
一个人的身影
一个人的身影 2021-01-16 03:40

Using .htaccess, I need to redirect all requests from

https://www.domain

to

https://domain

相关标签:
2条回答
  • 2021-01-16 04:03

    Assuming you have mod_rewrite enabled in your Apache configuration, you will need this in your .htaccess file.

    RewriteEngine On 
    RewriteCond %{SERVER_PORT} 80 
    RewriteRule ^(.*)$ https://example.com/$1 [R,L]
    
    0 讨论(0)
  • 2021-01-16 04:25
    RewriteEngine On
    RewriteCond HTTPS !on
    RewriteRule ^(.*)$ https://%{SERVER_NAME}%{REQUEST_URI} [R,L,QSA]
    

    This should do it

    via mod_rewrite manual

    [EDIT] swapped "www.example.com" to %{SERVER_NAME} so it redirects to same name you've tried to access, but via https...

    0 讨论(0)
提交回复
热议问题