htaccess 和 mod_rewrite codeigniter

发布于 2024-09-19 00:03:10 字数 1438 浏览 3 评论 0原文

我正在使用 codeigniter,下面是我的 htaccess 文件。但是,我希望可以通过我的domain.com/directory 在 codeigniter 应用程序之外访问单个目录。另一个目录是与codeigniter无关的论坛。我如何在 htaccess 中设置规则?我无法访问 http.conf

    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /

    #Removes access to the system folder by users.
    #Additionally this will allow you to create a System.php controller,
    #previously this would not have been possible.
    #'system' can be replaced if you have renamed your system folder.
    RewriteCond %{REQUEST_URI} ^system.*
    RewriteRule ^(.*)$ /index.php?/$1 [L]

    #When your application folder isn't in the system folder
    #This snippet prevents user access to the application folder
    #Submitted by: Fabdrol
    #Rename 'application' to your applications folder name.
    RewriteCond %{REQUEST_URI} ^application.*
    RewriteRule ^(.*)$ /index.php?/$1 [L]

    #Checks to see if the user is attempting to access a valid file,
    #such as an image or css document, if this isn't true it sends the
    #request to index.php
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule>

<IfModule !mod_rewrite.c>
    # If we don't have mod_rewrite installed, all 404's
    # can be sent to index.php, and everything works as normal.
    # Submitted by: ElliotHaughin

    ErrorDocument 404 /index.php
</IfModule>

I am using codeigniter and below is my htaccess file. However, i want a single directory to be accessable outside of the codeigniter app via my domain.com/directory. the other directory is a forum not related to codeigniter. how would i set up a rule in htaccess? i dont have access to http.conf

    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /

    #Removes access to the system folder by users.
    #Additionally this will allow you to create a System.php controller,
    #previously this would not have been possible.
    #'system' can be replaced if you have renamed your system folder.
    RewriteCond %{REQUEST_URI} ^system.*
    RewriteRule ^(.*)$ /index.php?/$1 [L]

    #When your application folder isn't in the system folder
    #This snippet prevents user access to the application folder
    #Submitted by: Fabdrol
    #Rename 'application' to your applications folder name.
    RewriteCond %{REQUEST_URI} ^application.*
    RewriteRule ^(.*)$ /index.php?/$1 [L]

    #Checks to see if the user is attempting to access a valid file,
    #such as an image or css document, if this isn't true it sends the
    #request to index.php
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule>

<IfModule !mod_rewrite.c>
    # If we don't have mod_rewrite installed, all 404's
    # can be sent to index.php, and everything works as normal.
    # Submitted by: ElliotHaughin

    ErrorDocument 404 /index.php
</IfModule>

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

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

发布评论

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

评论(2

未央 2024-09-26 00:03:10

这应该已经可以工作了。 RewriteCond %{REQUEST_FILENAME} !-d 告诉 mod_rewrite 忽略实际目录,RewriteCond %{REQUEST_FILENAME} !-f 告诉它忽略实际文件。

This should already work. RewriteCond %{REQUEST_FILENAME} !-d tells mod_rewrite to ignore actual directories, and RewriteCond %{REQUEST_FILENAME} !-f tells it to ignore actual files.

抚笙 2024-09-26 00:03:10

我用它来排除任何文件夹被解析为 codeigniter 框架作为控制器。
因此 www.domain.com/images/ 将作为普通文件夹运行,等等。您可以在其中放置 htaccess 的个人指令。祝你好运!

RewriteCond $1 !^(folders_to_exclude_from_CI|images|css|assets|resources|robots\.txt)

I use this to exclude any folder from being parsed to codeigniter framework as a controller.
So www.domain.com/images/ would run as normal folder, etc. There you can put your individual directives of htaccess. Best of luck!

RewriteCond $1 !^(folders_to_exclude_from_CI|images|css|assets|resources|robots\.txt)
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文