【问题标题】:HTACCESS file is not working properlyHTACCESS 文件无法正常工作
【发布时间】:2013-12-19 07:25:23
【问题描述】:
RewriteEngine on
Redirect 301 includes/config.php http:/mydomain.com/includes/index.php
Redirect 301 includes/blog_inc.php http://mydomain.com/includes/index.php

问题是只有第一个重定向是针对配置文件的。我有多个文件要重定向到这个包含文件夹中的 index.php。我该怎么做才能将所有请求重定向到includesincludes/index.php?我已将此 .htaccess 文件放在根目录中。

【问题讨论】:

    标签: php apache .htaccess redirect


    【解决方案1】:

    RedirectMatch 用于正则表达式:

    RedirectMatch 301 ^/includes/(?!index\.php).+$ /includes/index.php
    

    【讨论】:

    • 我应该把它放在根目录还是包含文件夹?
    • 而且它也给出了页面没有正确重定向的错误。我把它放在根目录...
    • 是的,它需要在根目录中,并且我修复了导致循环的代码。立即尝试。
    猜你喜欢
    • 2016-04-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-06-07
    • 2012-08-05
    相关资源
    最近更新 更多