问题描述
pretty确保基于各种例子(像一个)我正确设置事情:
Pretty sure based on various examples (like the one here) I set things up correctly:
1)我在网站的根目录
1) I created a file 'notfound.html' in the root directory of my site
2)我正在XAMPP,即得。 Apache Web服务器,所以根据我读过的东东,阿帕奇会在一个站点的根目录中的notfound.html时不存在的页面在浏览器中键入,如www.mysite.com/NotAValidPage。 HTML并使用的notfound.html为404错误消息
2) I'm running xampp, ie. Apache web server, so based on the stuff I've read, Apache looks for a notfound.html in the root directory of a site when a non-existent page is typed in the browser, such as www.mysite.com/NotAValidPage.html and uses that notfound.html for the 404 error message
下面是我已经试过和每次尝试的结果:
Here's what I've tried and the result of each attempt:
1test)我把我自己的notfound.html在我的网站的根目录,然后输入一个不存在的页
1test) I put my own notfound.html in my site's root directory and enter a non-existent page
1result)是不是用我的notfound.html,而是从(我猜的)我的Web服务器默认的404错误,将出现并说:
1result) my notfound.html is not used, but instead the default 404 error from (I guess) my web server, appears and says:
Object not found!
The requested URL was not found on this server. If you entered the URL manually please check your spelling and try
again.
If you think this is a server error, please contact the webmaster.
Error 404
localhost
2/14/2012 9:11:29 AM
Apache/2.2.17 (Win32) mod_ssl/2.2.17 OpenSSL/0.9.8o PHP/5.3.4 mod_perl/2.0.4 Perl/v5.10.1
2检验)我旁边增加了一个.htaccess文件到我的网站的根文件夹,并添加这个.htaccess文件中这一行:
2test) I next added an .htaccess file to the root folder of my site and added this line in this .htaccess file:
ErrorDocument 404 /notfound.html
然后我输入一个不存在的页面到我的浏览器。
then I typed a non-existent page into my browser.
2result)我还看到一个默认的404错误页面,而不是我的notfound.html,只是这一次的默认错误页说:
2result) I still see a default 404 error page, not my notfound.html, only this time the default error page says:
Not Found
The requested URL /mysite.com/indsadfaex.php was not found on this server.
Additionally, a 404 Not Found error was encountered while trying
to use an ErrorDocument to handle the request.
3test),然后我通过删除修改我的.htaccess文件/我的自定义404错误页面的文件名,如下所示名前:
的ErrorDocument 404的notfound.html
3test) I then modified my .htaccess file by removing the '/' before the name of my custom 404 error page filename as follows: ErrorDocument 404 notfound.html
3result)现在,当我输入我的网站名称,后跟一个不存在的页面,我再也看不到默认的404错误页面 - 浏览器窗口,除了在以下完全空白左上角:
3result) Now when I type my site name followed by a non-existent page, I no longer see the default 404 error page -- the browser window is completely blank except for the following at the top left corner:
notfound.html
不知道这里做什么,好像我错过了一些微妙的 - 任何想法真的AP preciated
Not sure what to do here, seems like I am missing some subtlety -- any ideas are really appreciated.
编辑:我怀疑它的问题,但也有在我的.htaccess文件2等语句重定向情况:
I doubt it matters but there are 2 other statements in my .htaccess file for redirection situations:
RewriteEngine on
RewriteRule ^([^/\.]+)$ theHandlerPage.php?theArgumentPassedIn=$1 [L]
这里的正则表达式只是说'去键入的URL的尽头并匹配字符当且仅当没有连续字符串'/'或''。在字符的连续流,然后通过$ _GET [theArgumentPassedIn']的方式把它们放到该文件theHandlerPage.php。
The regex here simply says 'go to the very end of the URL typed in and match a contiguous string of characters iff no '/' or '.' is in that contiguous stream of characters, then pass those in by way of $_GET[theArgumentPassedIn'] to the file theHandlerPage.php.
我不认为这重写规则即将在这里发挥作用,因为它不会在一个糟糕的页面名称相匹配,如因mysite的/ badpage.html'。在badpage.html。
I don't think this rewrite rule is coming into play here because it will not match on a bad page name such as mysite/badpage.html because of the '.' in badpage.html.
好吧 - 我发现了一个有点意外性的
Okay -- I discovered a bit of unexpectedness.
1)移动我的的notfound.html 错误文件到我的网站的父目录 - 而该文件位于在C之前:/ XAMPP / htdocs中/ mysite的/notfound.html
,我现在已经将该文件移到 C:/xampp/htdocs/notfound.html
1) I move my notfound.html error file to the parent directory of my site -- whereas before the file was located at c:/xampp/htdocs/mysite/notfound.html
, I have now moved this file to c:/xampp/htdocs/notfound.html
.
2),那么我使用的ErrorDocument 404 /notfound.html 我的的.htaccess
文件,该文件位于 C:/xampp/htdocs/mysite/.htaccess
2) then I use ErrorDocument 404 /notfound.html inside of my .htaccess
file, which is located at c:/xampp/htdocs/mysite/.htaccess
和现在当我在浏览器栏键入 mysite的/ aBadfilename.html
,我的 404的notfound.html 是显示了罚款。
And now when I type in the browser bar mysite/aBadfilename.html
, my 404 notfound.html is showing up fine.
但是,这是行不通的。我不能让我的的notfound.html
驻留在我的网站的父目录,因为我需要为每一个我开发的网站不同的notfound.html。我一定能够把我的网站的notfound.html在其文件夹的空间,即得。在 C:/ XAMPP / htdocs中/ mysite的
BUT THIS IS UNWORKABLE. I cannot have my notfound.html
reside in the parent directory of my site, because I need a different notfound.html for each site I develop. I must be able to put my site's notfound.html in its folder space, ie. inside c:/xampp/htdocs/mysite.
由于 C:/ XAMPP / htdocs中
是服务器上所有网站的根文件夹
Because c:/xampp/htdocs
is the root folder of all web sites on the server.
为什么我的Web服务器找我现场的的notfound.html
在 C:/ XAMPP / htdocs中
根目录,而不是 C:/ XAMPP / htdocs中/ mysite的
?毕竟,我输入的mysite / badfile.html使Web服务器(在我看来)应该明白,的notfound.html 是 C:/ XAMPP / htdocs中/ mysite的
文件夹的空间。
Why is my web server looking for my-site's notfound.html
in the c:/xampp/htdocs
root directory instead of c:/xampp/htdocs/mysite
? After all, I type mysite/badfile.html so the web server (in my opinion) should understand that notfound.html is in the c:/xampp/htdocs/mysite
folder space.
推荐答案
您使用虚拟主机?
如果是的话,我觉得有问题,打开你的的httpd-vhosts.conf
,寻找一条线在哪里的的DocumentRoot 的 C:/ XAMPP / htdocs中/ BLA /胡说/ mysite的/
和全路径写下来到主机,如果它不与目录路径工作,游玩。希望它帮助。
Are you using Virtual Hosts ?
if so, i think there is a problem, open your httpd-vhosts.conf
and look for a line where is DocumentRoot C:/xampp/htdocs/bla/blah/mysite/
and write down full path to a host, if it doesn't work play with Directory path. Hope it helps.
这篇关于的notfound.html未找到的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!