douzhu1188 2016-10-24 07:06
浏览 45

使用.htaccess将子域重定向到文件夹

I know this question has been asked many times on SO, but My problem is different and I'm not able to find the solution.

I've a Domain name(https://mydomainname.com) registered from GoDaddy and the site is hosted on AWS EC2. This site has a blog which is hosted on Azure with sub domain (https://blog.domainname.com).

The thing is, main site is on Amazon EC2 which is developed in Symfony and the Blog is on Azure developed in Wordpress. Now is there any way we can point sub-domain to the sub folder using .htaccess. (https://domainname.com/blog)

I think without transferring the files on single host it's not possible, then what is the work around to get it done in Symfony framework.

  • 写回答

1条回答 默认 最新

  • dongzhi4470 2016-10-24 10:51
    关注

    You will have to create redirect rule at your Azure hosting.

    In the root of the blog.domainname.com website, create a file named Web.config with contents as this:

    <?xml version="1.0" encoding="utf-8" ?>
    <configuration>
        <system.webServer>
            <rewrite>
                <rules>
                    <rule name="Redirect blog domain to main domain" stopProcessing="true">
                        <match url=".*" />
                        <conditions>
                            <add input="{HTTP_HOST}" pattern="^blog\.domainname\.com$" />
                        </conditions>
                        <action type="Redirect" url="http://domainname.com/blog/{R:0}" redirectType="Permanent" />
                    </rule>              
                </rules>
            </rewrite>
        </system.webServer>
    </configuration>
    
    评论

报告相同问题?

悬赏问题

  • ¥15 Arduino无法同时连接多个hx711模块,如何解决?
  • ¥50 需求一个up主付费课程
  • ¥20 模型在y分布之外的数据上预测能力不好如何解决
  • ¥15 processing提取音乐节奏
  • ¥15 gg加速器加速游戏时,提示不是x86架构
  • ¥15 python按要求编写程序
  • ¥15 Python输入字符串转化为列表排序具体见图,严格按照输入
  • ¥20 XP系统在重新启动后进不去桌面,一直黑屏。
  • ¥15 opencv图像处理,需要四个处理结果图
  • ¥15 无线移动边缘计算系统中的系统模型