dsmnedc798226 2015-02-24 15:45
浏览 50
已采纳

将所有无http请求重定向到https + www(子域除外)

I have a bit of problem here while creating .htaccess file for proper redirection. I need to redirect all requests to https with www except subdomains.

This is the scenario:

http://example.com-> https://www.example.com
https://example.com-> https://www.example.com
http://www.example.com-> https://www.example.com
http://subdomain.example.com-> http://subdomain.example.com[unchanged]
or
http://subdomain.example.com-> https://www.example.com/sites/subdomain  

Any help is highly appreciated.

  • 写回答

1条回答 默认 最新

  • dongye9453 2015-02-24 15:49
    关注

    In the htaccess file in your document root, add this to the top:

    RewriteEngine On
    RewriteCond %{HTTPS} off [OR]
    RewriteCond %{HTTP_HOST} ^example\.com$ [NC]
    RewriteRule ^(.*)$ https://www.example.com/$1 [L,R=301]
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥60 ESP32怎么烧录自启动程序
  • ¥50 html2canvas超出滚动条不显示
  • ¥15 java业务性能问题求解(sql,业务设计相关)
  • ¥15 52810 尾椎c三个a 写蓝牙地址
  • ¥15 elmos524.33 eeprom的读写问题
  • ¥15 使用Java milo连接Kepserver服务端报错?
  • ¥15 用ADS设计一款的射频功率放大器
  • ¥15 怎么求交点连线的理论解?
  • ¥20 软件开发方法学习来了
  • ¥15 微信小程序商城如何实现多商户收款 平台分润抽成