我正在使用带有绝对路径的codeigniter。我的图片和css都在css,img文件夹中,我使用下面的代码来隐藏index.php。 CSS工作正常,但通过img标签的图像不会加载。这很奇怪但是使用带有url()的css会加载它。 .htaccess
有什么问题RewriteEngine on
RewriteCond %{HTTP_HOST} ^www\.(.*)$
RewriteRule ^(.*)$ http://%1/$1 [R=301,L]
RewriteEngine on
RewriteCond $1 !^(index\.php|css|js|eot|svg|ttf|png|jpg|images|stylesheets|favicon.ico|scripts|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]
答案 0 :(得分:0)
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ http://%1%{REQUEST_URI} [R=301,QSA,NC,L]
RewriteBase /
### Canonicalize codeigniter URLs
# If your default controller is something other than
# "welcome" you should probably change this
RewriteRule ^(.*)/index/?$ $1 [L,R=301]
###
# 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]
# 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]
Options All -Indexes
# Without mod_rewrite, route 404's to the front controller
ErrorDocument 404 /index.php
我的.htaccess文件内容它像怪物一样工作。你能试试吗?