当我将我的浏览器指向网站site.com/index.php/"non-existent-dir“时显示index.php没有css的页面

时间:2016-08-28 01:23:54

标签: php apache .htaccess

这是我的.htaccess文件:

ErrorDocument 404 /404.html
Options +FollowSymlinks
Options -Indexes


RewriteEngine On

RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]

no css styles applied

我不希望页面显示...是不是应该显示我配置的te 404页面?

index.php /不是目录

1 个答案:

答案 0 :(得分:0)

这是因为你没有使用样式/图像href和src的绝对路径。

<link rel="stylesheet" type="text/css" href="/design/style.css"/>
<img src="/design/mylogo.php"/>

正如您所看到的,我已添加/在路径前面,因此我指向浏览器以在根位置搜索文件。当您使用网址http://example.com/index.php/somename时,浏览器会尝试在此位置http://example.com/index.php/somename/design/style.csshttp://example.com/index.php/somenamde/design/mylogo.png上找到css /图像。