问题描述
请考虑以下网站结构:
www.mydomain.com /
www.mydomain.com/
www。 mydomain.com/index.php
www.mydomain.com/index.php
www.mydomain.com/404.php
www.mydomain.com/404.php
www.mydomain。 com / css
www.mydomain.com/css
www.mydomain.com/blog /
www.mydomain.com/blog/
如何显示404.php页面在以下情况下,我的根目录及其stylinf和css一起存在:
How can I show the 404.php page that exists in my root directory along with its stylinf and css, in the following cases:
-
当用户尝试访问非-现有文件夹和/或其内容?
示例:www.mydomain.com/nofolder
When user tries to access a non-existing folder and/or its contents?Example: www.mydomain.com/nofolder
当用户尝试访问嵌套的不存在的文件夹时?
示例:www.mydomain.com/nofolder1/nofolder2/nofolder3 /
When user tries to access nested non-existing folders?Example: www.mydomain.com/nofolder1/nofolder2/nofolder3/
当用户尝试访问不存在的文件时嵌套的不存在的文件夹?
示例:www.mydomain.com/nofolder1/nofolder2/index.php
When user tries to access non-existing file nested non-existing folders?Example: www.mydomain.com/nofolder1/nofolder2/index.php
我已经有一个.htaccess文件,当在我的网站的根文件夹中访问不存在的页面时显示404页面。我当前的.htaccess文件:
I already have a .htaccess file that shows the 404 page when a non-existent page is accessed in the root folder of my website. My current .htaccess file:
ErrorDocument 404 /404.php
上面的代码显示了访问不存在的文件夹(例如:www.mydomain.com/nofolder)时我的404.php页面的CSS剥离版本。我需要完整显示所有CSS和样式。为了方便用户使用,我认为最好保留原样输入的URL,但仍显示404页面。怎么做?
The above code shows the CSS stripped version of my 404.php page when a non-existent folder (Example: www.mydomain.com/nofolder) is accessed. I need to show all the CSS and styling intact. For user friendliness, I think its best to retain the URL that was entered in as it is, but still show the 404 page. How can this be done?
编辑1:
我需要显示无需在CSS中使用绝对链接。我该怎么做?
I need to show this without using absolute links for the CSS. How can I do this?
推荐答案
CSS链接必须使用绝对路径。代替此:
You must use absolute path for the CSS link. Instead of this:
<link rel="stylesheet" type="text/css" href="css" />
使用此命令:
<link rel="stylesheet" type="text/css" href="/css" />
这篇关于找不到页面/文件夹时重定向到/在根目录中显示404页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!