分享

写回答

发帖

[介绍] 404错误页面设置_linux

GoDaddy GoDaddy 2649 人阅读 | 4 人回复

发表于 2008-11-7 15:20:05 | 显示全部楼层 |阅读模式

Setting a 404 Page on Subdomains and Aliased Domains
This article relates solely to Linux hosting plans.


404 Errors on subdomains
For each subdomain that points to a different folder, you need to put a new .htaccess file with executable permissions in that folder that looks like this:
  1. ErrorDocument 404 /notfound.html
复制代码
Make sure to change "notfound.html" to point to the file you would like displayed upon a 404 error. Your hosting account will know that "/notfound.html" translates to a path that is relative to the your subdomain's root directory. For instance, if you uploaded your .htaccess file and notfound.html to your "blog.coolexample.com" subdomain, in your FTP client, you'll notice that you're the "/blog/" directory. However, if a user encounters a 404 error on blog.coolexample.net your hosting account will know that it's already in "/blog/" because that's the root directory of your subdomain, and it will display the contents "/blog/notfound.html".

404 Errors on non-primary domains
Non-primary domains that point to your hosting account's root do not require any special configuration. Using the Hosting Control Center to set the 404 error page will control all of the error pages for domains that point to your root domain folder. Your root domain folder is the path "/". For example, if you set your 404 errors to point to "/notfound.html" then if the user encounters an error on coolexample.com, they will see coolexample.com/notfound.html. If the user encounters an error on coolexample.org, coolexample.net, or coolexample.us, they will still see the contents "/notfound.html".

If you want to use change some aspect of the page dynamically to match the domain, you can use a php file, and access $_SERVER['SERVER_NAME']. That will return the Fully Qualified Domain Name (FQDN) of the current request as determined by your hosting account. For example, if you used this .htaccess file:
  1. ErrorDocument 404 /notfound.php
复制代码
And notfound.php looks like this:
  1. The file you're looking for on <?php echo $_SERVER['SERVER_NAME']; ?>cannot be found.
复制代码
If the user encounters a 404 error on coolexample.com, they will see "The file ... on coolexample.com ..." If the user encounters a 404 error on coolexample.net they will see "The file ... on coolexample.net ..."

NOTE:Use the Hosting Control Center to manage your 404 error pages on your root domain, or any non-primary domains that point to your root domain folder. Uploading a custom .htaccess file to your root domain folder can cause potential conflicts and unexpected site behavior.


[ 本帖最后由 蜘蛛侠 于 2008-11-7 03:24 PM 编辑 ]

评分

参与人数 1金币 +2 收起 理由
add.c + 2

查看全部评分

回答|共 4 个

add.c

发表于 2008-11-7 15:56:30 | 显示全部楼层

linux主机用的

ffnn

发表于 2008-11-7 15:59:27 | 显示全部楼层

我也是linux的,和我的不杂一样。我是放置一个 404.shtml 的页面

ffnn

发表于 2008-11-7 16:00:02 | 显示全部楼层

全是E文,不然都该加精

dzbz

发表于 2010-9-12 17:03:36 | 显示全部楼层

您需要登录后才可以回帖 登录 | 注册

本版积分规则