很确定基于各种例子(如这里的一个),我正确地设置:
1)我在我的网站的根目录中创build了一个文件'notfound.html'
2)我正在运行xampp,即。 Apache Web服务器,所以基于我读过的东西,Apache在浏览器中input一个不存在的页面(如www.mysite.com/NotAValidPage)时会在站点的根目录中查找notfound.html。 HTML,并使用notfound.html 404错误消息
以下是我所尝试的和每次尝试的结果:
如何在云服务器上设置/configurationlaravel项目
将Grunt / Gulp和Livereload集成到现有的服务于PHP / Zend的Apache服务器上
在Mac OS X Mountain Lion上编译apache2的问题
1test)我把我自己的notfound.html放在我的网站的根目录下,然后input一个不存在的页面
1result)我的notfound.html没有被使用,而是从(我猜)我的Web服务器,默认的404错误出现,并说:
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
2test)接下来我将一个.htaccess文件添加到我的网站的根文件夹,并在这个.htaccess文件中添加了这一行:
ErrorDocument 404 /notfound.html
2result)我仍然看到一个默认的404错误页面,而不是我的notfound.html,只是这次默认的错误页面显示:
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)然后通过删除我的自定义404错误页面文件名的名称之前的'/'来修改我的.htaccess文件,如下所示: ErrorDocument 404 notfound.html
3result)现在,当我键入我的站点名称,然后是一个不存在的页面,我不再看到默认的404错误页面 – 浏览器窗口是完全空白,除了在左上angular以下:
notfound.html
不知道在这里做什么,似乎我错过了一些微妙 – 任何想法真的很感激。
编辑:我怀疑这个问题,但有2个其他语句在我的.htaccess文件的redirect的情况下:
RewriteEngine on RewriteRule ^([^/.]+)$ theHandlerPage.PHP?theArgumentPassedIn=$1 [L]
这里的正则expression式只是说'进入inputURL的最后,匹配一个连续的string,如果没有'/'或'。' 是在连续的字符stream中,然后通过$ _GET [theArgumentPassedIn']传递给文件theHandlerPage.PHP。
我不认为这个重写规则在这里起作用,因为它不会匹配坏页面名称,比如mysite / badpage.html,因为'。' 在badpage.html中。
好的 – 我发现了一点意外。
1)我将我的notfound.html错误文件移动到我的站点的父目录 – 而在文件位于c:/xampp/htdocs/mysite/notfound.html ,现在我已经将该文件移动到c:/xampp/htdocs/notfound.html 。
2)然后我使用ErrorDocument 404 / notfound.html里面的.htaccess文件,它位于c:/xampp/htdocs/mysite/.htaccess
而现在,当我在浏览器栏中inputmysite/aBadfilename.html ,我的404 notfound.html显示正常。
但这是联合的。 我不能让我的notfound.html驻留在我的网站的父目录,因为我需要一个不同的notfound.html为我开发的每个网站。 我必须能够把我的网站的notfound.html在其文件夹空间,即。 在c:/xampp/htdocs/mysite.
因为c:/xampp/htdocs是服务器上所有网站的根文件夹。
为什么我的Web服务器在c:/xampp/htdocs根目录中而不是c:/xampp/htdocs/mysite查找我网站的notfound.html ? 毕竟,我inputmysite / badfile.html,所以Web服务器(在我看来)应该明白, notfound.html是在c:/xampp/htdocs/mysite文件夹空间。
TemplateSyntaxError:在呈现时捕获ImportError:无法导入名称utils
Symfony 2新鲜安装没有url的作品
你在使用虚拟主机吗?
如果是这样,我认为有一个问题,打开你的httpd-vhosts.conf并找到一个在哪里是DocumentRoot C:/xampp/htdocs/bla/blah/mysite/和写下一个主机的完整路径,如果它doesn没有工作与目录路径玩。 希望能帮助到你。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。