【问题标题】:How do I enable .php extensions on my pages?如何在我的页面上启用 .php 扩展?
【发布时间】:2016-03-06 20:20:57
【问题描述】:

我目前正在制作一系列页面,但我遇到了问题。 我下载了这个项目的基础,其中包括 .htaccess 和 web.config 文件。 当我导航到我网站的 url 时,它会自动重定向到 http://example.com/index,这是正确的,我希望它这样做,但我希望它改为显示 http://example.com/index.php。 (.php 扩展名) 我在 Windows VPS 2008 VPS 上的 IIS 7 Web 服务器上运行,安装了 Helicon ape 以及 url 重写、iis 推荐配置和 php。

【问题讨论】:

    标签: php .htaccess iis web-config


    【解决方案1】:

    您只需要 DirectoryIndex 中的 home.php 即可使其正常工作。请记住,这是在根项目的 .htaccess 文件中使用的: DirectoryIndex home.php

    【讨论】:

    • 这不起作用,当我把它放在 .htaccess 中然后访问 url - example.com/index.php 它只是将我重定向到 example.com/index
    • 我假设您已将其配置为允许 .htaccess 文件。如果不是,则必须修改配置文件 (httpd.conf) 1.Create a .htaccess file in your web root. 2.Add the line... DirectoryIndex index.php 中的设置
    • 我发现,如果我从 web.config 中删除此 <rule name="Imported Rule 2-2"> <match url="^([a-zA-Z0-9_-]+)(|/)$" ignoreCase="false" /> <action type="Rewrite" url="index.php?url={R:1}" appendQueryString="false" /> </rule>,它会将网站发送到 example.com/404,这是否有助于找到允许扩展 .php 的解决方案?
    • 我还发现,如果我从这段代码 sn-p:<match url="^([a-zA-Z0-9_-]+)(|/)$" 中删除 (|/)$ 它允许您放置 example.com/index.php 并将您发送到它但是当您访问 example.com 时,它不会自动显示 /index。我认为这与比赛网址有关。
    猜你喜欢
    • 2012-11-12
    • 1970-01-01
    • 1970-01-01
    • 2022-07-24
    • 1970-01-01
    • 2020-09-30
    • 2011-01-07
    • 2019-06-09
    • 1970-01-01
    相关资源
    最近更新 更多