douzhuanqian8244 2015-08-23 23:22 采纳率: 100%
浏览 55
已采纳

透明地将http://my-domain-name.com重定向到https://my-domain-name.com/web

I have a website with my front controller in a subdirectory. Then I would like to transparently redirect root folder of the site to subdirectory. Moreover, I have SSL enabled and want to force it for the site.

I succeeded in transparently redirecting root folder to subdirectory by doing this in .htaccess:

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^(.*)$ web/$1 [QSA,L]
</IfModule>

So I decided to add https to the RewriteRule like this : RewriteRule ^(.*)$ https://my-domain-name.com/web/$1 [QSA,L]. But I don't get what I want. In fact, I get https forcing but the transparent root folder to subdirectory redirection does not work anymore. I got in my address bar : https://my-domain-name.com/web though my wish is to have https://my-domain-name.com.

  • 写回答

1条回答 默认 最新

  • dongmoyu0336 2015-08-23 23:36
    关注

    Your added rule is implicitly treated like a redirect. Just put it prior to the rule that does the web/ rewrite. This allows you to change the protocol first then continue with your internal rewriting after the request returns on https.

    edit: More detail on HTTPS redirect: https://wiki.apache.org/httpd/RewriteHTTPToHTTPS

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度