Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/apache/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 由于子目录的.htaccess重写,CodeIgniter未加载资产_Php_Apache_.htaccess_Codeigniter_Mod Rewrite - Fatal编程技术网

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

Php 由于子目录的.htaccess重写,CodeIgniter未加载资产,php,apache,.htaccess,codeigniter,mod-rewrite,Php,Apache,.htaccess,Codeigniter,Mod Rewrite,这是我正在处理的网站:example.com我所有的Codeigniter文件都在子目录“dir1”中 对于我的根目录,这里是.htaccess文件: Options +FollowSymLinks -MultiViews RewriteEngine On RewriteBase / RewriteCond %{HTTP_HOST} ^(www.)?example.com$ RewriteCond %{REQUEST_URI} !^/dir1/ RewriteCond %{REQUEST

这是我正在处理的网站:example.com我所有的Codeigniter文件都在子目录“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文件:(codeigniter文件在这里)

如果我将我的基本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]
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]