从url(codeigniter.htaccess)中删除index.php时,会阻止文件显示

从url(codeigniter.htaccess)中删除index.php时,会阻止文件显示,.htaccess,codeigniter,.htaccess,Codeigniter,我正在使用codeigniter,我试图通过创建.htaccess文件从url中删除index.php 内容包括: RewriteEngine on RewriteCond $1 !^(index\.php|images|robots\.txt) RewriteRule ^(.*)$ /index.php/$1 [L] 这种方法将在xampp服务器上运行。 但当我上传网站时,不幸的是出现了一个问题: 我有一个名为“文件”的文件夹和it内容子文件夹:图像、css、js、swf、上载。 这些文件夹

我正在使用codeigniter,我试图通过创建.htaccess文件从url中删除index.php 内容包括:

RewriteEngine on
RewriteCond $1 !^(index\.php|images|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]
这种方法将在xampp服务器上运行。 但当我上传网站时,不幸的是出现了一个问题:

我有一个名为“文件”的文件夹和it内容子文件夹:图像、css、js、swf、上载。 这些文件夹中的每个文件都无法查看,浏览器显示在那里找不到该文件。


有什么帮助吗?

请确保您也排除了这些帮助:

RewriteEngine on
RewriteCond $1 !^(index\.php|images|robots\.txt|css|swf|upload)
RewriteRule ^(.*)$ /index.php/$1 [L]

这是我的.htaccess文件-应该适合您:

Options -Indexes
Options +FollowSymLinks

# Set the default file for indexes
DirectoryIndex index.php

<IfModule mod_rewrite.c>

    # activate URL rewriting
    RewriteEngine on

    # do not rewrite links to the documentation, assets and public files
    RewriteCond $1 !^(files|css|js|swfimages|assets|uploads|captcha)

    # do not rewrite for php files in the document root, robots.txt or the maintenance page
    RewriteCond $1 !^([^\..]+\.php|robots\.txt|crossdomain\.xml|maintenance\.html)

    # but rewrite everything else
    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.
    ErrorDocument 404 index.php
</IfModule>  
选项-索引
选项+FollowSymLinks
#设置索引的默认文件
DirectoryIndex.php
#激活URL重写
重新启动发动机
#不要重写指向文档、资产和公共文件的链接
1美元^(文件| css | js | swfimages |资产|上传|验证码)
#不要在文档根、robots.txt或维护页面中重写php文件
1美元^([^\..]+\.php | robots\.txt | crossdomain\.xml | maintenance\.html)
#但是重写其他的一切
重写规则^(.*)$index.php/$1[L]
#如果我们没有安装mod_rewrite,所有404
#可以发送到index.php,一切正常。
ErrorDocument 404 index.php

这是我的.htaccess文件。我的理解是,对于任何试图访问但不存在的文件或目录,它都将转发到Codeigniter

任何存在的东西都可以正常工作,不需要单独排除。这将节省您每次添加新目录或文件夹时的时间和麻烦,因为它不需要您编辑此文件

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

这对我们很有用,但我的理解可能不正确。希望它能帮助你试试这个,我想它能解决你的问题

RewriteEngine on
RewriteCond $1 !^(index\.php|robots\.txt|files\/images|files\/css|files\/js|files\/swf|files\/upload)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
您必须告诉服务器不要将这些目录转移到index.php,这样做的一行代码是:

RewriteCond $1 !^(index\.php|robots\.txt|files\/images|files\/css|files\/js|files\/swf|files\/upload)

多谢各位。这很好:

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

我有另一个网站和next index.php我有一个名为files的文件夹,这个文件夹包含很多文件夹,我应该把它们的所有名称和子目录的名称放在其中吗

错误日志告诉你的是什么?谢谢你,我用了最后一个日志并处理了文件。但我应该把所有的子目录?因为我有另一个网站,我有一个文件夹,有很多子目录,我试图把主目录的名称放在index.php附近,但它不起作用。是的,你应该包括你不想让php处理的所有子文件夹/文件夹。谢谢。这很有效。我有另一个网站和next index.php我有一个名为files的文件夹,这个文件夹包含很多文件夹,我应该把它们的所有名称和子目录的名称都放在其中吗?不知道为什么这不是更高的投票率,这是迄今为止最好的解决方案。