【问题标题】:codeigniter htaccess exception for a specific folder特定文件夹的codeigniter htaccess异常
【发布时间】:2011-12-19 07:18:09
【问题描述】:

下面是我用于 codeigniter setup 的 htaccess 文件,它将 a/b 转换为 index.php/a/b 但是,我想添加一个例外,即如果 a=cometchat 则不会进行重写。

请帮忙

<IfModule mod_rewrite.c> 

  # Make sure directory listing is disabled
    Options +FollowSymLinks -Indexes
    RewriteEngine on

    # Keep people out of codeigniter directory and Git/Mercurial data
    RedirectMatch 403 ^/(system|\.git|\.hg).*$

    # Send request via index.php (again, not if its a real file or folder)
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d

    <IfModule mod_php5.c>
        RewriteRule ^(.*)$ index.php/$1 [L]
    </IfModule>

    <IfModule !mod_php5.c>
        RewriteRule ^(.*)$ index.php?/$1 [L]
    </IfModule>

</IfModule>

【问题讨论】:

  • RewriteCond $1 !^(index\.php|cometchat) 是我在 RewruteRule 之前所拥有的(替换为你的例外)

标签: .htaccess codeigniter mod-rewrite rewrite


【解决方案1】:

添加这一行:

RewriteCond $1 !^(index\.php|folder1|folder2|img|shared)

在每个RewriteRule 上方,并更改/添加文件夹。

所以:

<IfModule mod_rewrite.c> 

  # Make sure directory listing is disabled
    Options +FollowSymLinks -Indexes
    RewriteEngine on

    # Keep people out of codeigniter directory and Git/Mercurial data
    RedirectMatch 403 ^/(system|\.git|\.hg).*$

    # Send request via index.php (again, not if its a real file or folder)
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d

    <IfModule mod_php5.c>
        RewriteCond $1 !^(index\.php|folder1|folder2|img|shared)
        RewriteRule ^(.*)$ index.php/$1 [L]
    </IfModule>

    <IfModule !mod_php5.c>
        RewriteCond $1 !^(index\.php|folder1|folder2|img|shared)
        RewriteRule ^(.*)$ index.php?/$1 [L]
    </IfModule>

</IfModule>

【讨论】:

    猜你喜欢
    • 2015-02-01
    • 1970-01-01
    • 1970-01-01
    • 2021-12-17
    • 2017-09-08
    • 2015-12-11
    • 2015-03-25
    • 2010-12-11
    • 2021-08-10
    相关资源
    最近更新 更多