特定文件夹的 codeigniter htaccess 异常

发布于 2024-12-13 13:06:20 字数 771 浏览 0 评论 0原文

下面是我用于 codeigniter 设置的 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>

Below is my htaccess file for codeigniter setup , which converts a/b to index.php/a/b
However, I want to add an exception that if a=cometchat then, it will not do the rewrite.

Please help

<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>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

动次打次papapa 2024-12-20 13:06:20

添加此行:

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>

Add this line:

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

above each RewriteRule, and change/add folders.

so:

<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>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文