简体   繁体   English

.htaccess问题与Codeigniter设置相关

[英].htaccess question in association with codeigniter setup

So I am fairly noobish at .htaccess rewriting. 因此,我不太喜欢.htaccess重写。

Currently this is my setup for my codeigniter setups: 目前,这是我的codeigniter设置的设置:

RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !index.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]

This works fine when I am rewriting EVERYTHING to the index.php. 当我将所有内容重写为index.php时,此方法工作正常。 The problem is, I am trying to install a forum to www.site.com/forums/ and of course this doesnt work because it rewrites it to the main index.php. 问题是,我试图在www.site.com/forums/上安装一个论坛,但是这当然不起作用,因为它将其重写为主要index.php。

Any suggestions? 有什么建议么?

Here is the CodeIgniter .htaccess that I use: 这是我使用的CodeIgniter .htaccess:

<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
    RewriteCond %{REQUEST_URI} !^public.*
    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>

Generally speaking, the 一般来说,

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

rules should prevent existing files or directories from being rewritten to index.php, but you can also duplicate the 规则应防止现有文件或目录被重写为index.php,但您也可以复制

RewriteCond %{REQUEST_URI} !^public.*

rule to be 规则是

RewriteCond %{REQUEST_URI} !^forums.*

and it should accomplish the same goal, in your case. 在您的情况下,它应该实现相同的目标。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM