【问题标题】:Add exception to mod_rewrite rule to not fire for specific directory向 mod_rewrite 规则添加例外以不针对特定目录触发
【发布时间】:2016-11-12 04:06:34
【问题描述】:

我的网站上有一个重写规则,例如

example.com/category.php?cat=this becomes example.com/this/

example.com/category.php?cat=this&post=example becomes example.com/this/example/

这是 .htaccess 中定义的 mod_rewrite:

<IfModule mod_rewrite.c>

    # http://www.generateit.net/mod-rewrite/index.php

    # Tell PHP that the mod_rewrite module is ENABLED.
    SetEnv HTTP_MOD_REWRITE On

    RewriteEngine on

    RewriteRule ^([^/]*)/$              category.php?cat=$1 [L]
    RewriteRule ^([^/]*)/([^/]*)/$      post.php?cat=$1&post=$2 [L]
    RewriteRule ^blog-([^/]*).php$      default.php?page=$1 [L]

</IfModule>

我需要在网站上设置 OSCart,并将其放在一个名为 printshop 的文件夹中,以便通过以下方式访问它:

example.com/printshop/

我将如何修改我的 mod_rewrite 以便它不会认为我在调用此页面:

example.com/category.php?cat=printshop

例如将 mod_rewrite 更改为不针对特定目录触发?

【问题讨论】:

    标签: apache .htaccess mod-rewrite


    【解决方案1】:

    对不起 - 一个简单的谷歌搜索让我得到了答案:

    RewriteRule ^printshop - [L,NC]
    

    在这里找到: How do I ignore a directory in mod_rewrite?

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-03-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-01-13
      • 1970-01-01
      相关资源
      最近更新 更多