【问题标题】:XAMPP - Rewrite Rule doesn't workXAMPP - 重写规则不起作用
【发布时间】:2016-01-11 08:00:30
【问题描述】:

我正在使用 XAMPP (Windows 7),在 httpd.conf 中我有:

  • 允许全部覆盖
  • Lo​​adModule rewrite_module modules/mod_rewrite.so(未注释)

htdocs 目录中,我有一个名为 shop 的子目录,我的网站在哪里。在 shop 内,我还有一个名为 shirts 的子目录,其中包含该文件:

  • shirts.php

要打开它,您只需输入以下网址:http://localhost/shop/shirts/shirts.php

但是,当我只打开 http://localhost/shop/shirts/ - 浏览器会显示一个目录列表,我希望它打开 shirts.php。

所以,在 /shirts 目录中,我创建了以下 .htaccess 文件:

RewriteEngine On
RewriteRule ^shirts/$ /shop/shirts/shirts.php

但它不起作用。你知道我做错了什么,为什么这不起作用?

提前致谢!

【问题讨论】:

    标签: php .htaccess xampp rewrite


    【解决方案1】:

    试着在你的 .htaccess 文件中写下这个DirectoryIndex index.php shirts.php

    【讨论】:

    • 请指定在 .htaccess 中的确切位置放置此行。这可能很重要。
    • 这行得通,谢谢。我看了一些视频课程,不明白为什么作者使用RewriteEngine On RewriteRule ^shirts/$ /shop/shirts/shirts.php 并且在他安装 XAMPP(本地主机)时工作,但它对我不起作用?不管怎样,你的回答解决了我的问题。
    猜你喜欢
    • 2018-11-20
    • 2013-07-06
    • 1970-01-01
    相关资源
    最近更新 更多