【问题标题】:Redirect URLS with Apache mod_rewrite使用 Apache mod_rewrite 重定向 URL
【发布时间】:2023-03-18 11:08:01
【问题描述】:

我正在尝试重定向在我的 Apache Web 服务器上收到的 URL。基本上当我输入

localhost/index.html

我希望网站将我重定向到 htdocs 中的 readme.html 文件。 index.htmlreadme.html 文件都保存在 htdocs 中。我查看了 Apache 文档,但似乎无法正常工作。下面我在httpd.conf 文件中包含了到目前为止我编写的代码。

DocumentRoot "usr/local/apache2/htdocs"
<Directory "/htdocs">
Options FollowSymLinks
AllowOverride None
Order allow,deny
allow from all
RewriteEngine On
RewriteBase /
RewriteRule ^index.html readme.html [PT]
</Directory>

我已尝试在浏览器上查找 "localhost/index.html" ,但我看到的是 index.html 页面。除非我看错了。 谢谢

【问题讨论】:

    标签: apache mod-rewrite server-side httpd.conf


    【解决方案1】:

    试试这个

    <Directory "usr/local/apache2/htdocs">
    #your other code here#
    RewriteEngine On
    RewriteBase /
    RewriteRule ^index\.html$ readme.html [R,NC]
    </Directory>
    

    清除缓存和删除临时 Internet 文件总是好的。

    【讨论】:

      猜你喜欢
      • 2012-11-12
      • 2014-07-04
      • 1970-01-01
      • 2016-02-25
      • 1970-01-01
      • 1970-01-01
      • 2011-11-10
      • 2014-09-05
      • 2019-02-02
      相关资源
      最近更新 更多