为mod_rewrite规则添加例外以不为特定目录触发

时间:2016-07-09 20:33:11

标签: apache .htaccess mod-rewrite

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

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

e.g。将mod_rewrite更改为不针对特定目录触发?

1 个答案:

答案 0 :(得分:1)

抱歉 - 一个简单的谷歌搜索得到了答案:

RewriteRule ^printshop - [L,NC]

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