【问题标题】:How to write multiple rule in Htaccess如何在 Htaccess 中编写多个规则
【发布时间】:2012-04-02 16:09:32
【问题描述】:

我正在为我的网站使用 codeigniter 框架,并且我还有一个博客网站,它也是在 wordpress 中完成的。我的网站网址是这样的https://mydomain.com 而我的博客网址是https://mydomain.com/blog。我已经为我的网站编写了这样的 htaccess

RewriteRule ^([^.]+)$ index.php/profile/fundraiser/$1

每当我访问我的博客站点时,它总是重定向到配置文件控制器(在 htaccess 中定义)。如果 url 是https://mydomain/blog 它应该重定向到我的博客,在其他情况下它应该重定向到配置文件控制器。我可以为此编写多个 Htaccess 规则,因为我已将两个文件放在同一个域中吗?有谁请帮帮我。

【问题讨论】:

    标签: php .htaccess codeigniter


    【解决方案1】:

    你必须像下面这样使用重写条件 -

    RewriteCond $1 !^(blog)
    RewriteRule ^([^.]+)$ index.php/profile/fundraiser/$1
    

    即只有当 URL 不包含博客时,它才会重定向到个人资料页面。您可以为每个规则添加更多条件。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-07-07
      • 1970-01-01
      • 2017-01-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-02-14
      • 1970-01-01
      相关资源
      最近更新 更多