【问题标题】:Subdomain with index.shtml as default page?以 index.shtml 作为默认页面的子域?
【发布时间】:2020-06-22 22:00:15
【问题描述】:

有没有办法使用 .shtml 作为子域的默认页面?我需要这种方式,因为我的网站使用 HTML 包含。可能在 .htaccess 中添加一些东西?

【问题讨论】:

    标签: .htaccess subdomain shtml


    【解决方案1】:

    我假设您的服务器上已经启用了服务器端包含(这是另一个答案正在解决的问题),否则您的网站将无法像您所说的那样使用“HTML 包含”。

    要将.shtml 文件(例如index.shtml)设置为子域的默认页面,您需要在子域根目录下的.htaccess 文件中设置适当的DirectoryIndex。例如:

    DirectoryIndex index.shtml
    

    【讨论】:

    • 我已经尝试过了,很遗憾,它并没有改变任何东西。
    • 您请求的 URL 是否为:https://subdomain.example.com/?当您请求此 URL 时实际发生了什么?您希望设置为默认的.shtml 文件是什么? .htaccess 文件中还有其他指令吗?
    • 您使用的是哪个版本的 Apache?
    • 是的,网址是qm.exploreloudoncounty.com。访问时收到内容编码错误。我尝试将文件更改为 index.html 并且它会加载,但显然不正确,因为它需要是 index.shtml 才能显示服务器端包含。我尝试在 .htaccess 中的 DirectoryIndex 之后将 index.shtml 和 index.html 一起包含,并且只包含 index.shtml。
    • 我不确定我使用的是哪个版本的 Apache - 我该如何找到?
    【解决方案2】:

    您应该在虚拟主机的定义中添加:

    Options +Includes
    AddType text/html .shtml
    AddOutputFilter INCLUDES .shtml
    

    你可以找到more info in the apache documentation

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-03-18
      • 2019-07-29
      • 2020-08-25
      • 2015-02-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多