由于子目录的.htaccess重写,CodeIgniter未加载资产


CodeIgniter not loading assets due to .htaccess rewrite for subdirectory

这是我正在处理的网站:example.com我所有的Codeigner文件都在子目录"dir1"中。

对于我的根目录,这里有.htaccess文件:

Options +FollowSymLinks -MultiViews
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^(www.)?example.com$ 
RewriteCond %{REQUEST_URI} !^/dir1/ 
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /dir1/$1 
RewriteCond %{HTTP_HOST} ^(www.)?example.com$ 
RewriteRule ^(.*)$ dir1/index.php?$1 [L]

这是我的"wework"目录的.htaccess文件:(代码点火器文件在这里)

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

如果我将我的基本url从example.com更改为example.com/dir1,那么它可以正常工作,但它会在所有url中添加"dir1"子目录名。请帮助我如何加载我的资产。感谢

编辑:

我的"assetss"文件夹在"dir1"目录中。但当我在浏览器中加载我的网站并在浏览器中查看源代码时,它显示:

<link rel="stylesheet" type="text/css" href="http://example.com/assetss/css/style.css"/>

但我的资产在这里:example.com/dir1/assetss-

我使用的是godaddy服务器,我的域被配置为将我的文件上传到"dir1"目录。请帮帮我。再次感谢

在第一条规则结束时,尝试添加[L],然后对于第二条规则,包括相同的!-f!-d条件:

Options +FollowSymLinks -MultiViews
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^(www.)?example.com$ 
RewriteCond %{REQUEST_URI} !^/dir1/ 
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /dir1/$1 [L]
RewriteCond %{HTTP_HOST} ^(www.)?example.com$ 
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ dir1/index.php?$1 [L]