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]
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 c程序不知道为什么得不到结果
  • ¥40 复杂的限制性的商函数处理
  • ¥15 程序不包含适用于入口点的静态Main方法
  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置