为不存在的子域创建错误页面 [英] Creating an error page for a subdomain that doesn't exist
问题描述
noexist.example.com - >示例。 com / 404.php?subdomain = noexist(或没有查询字符串,如果HTTP_REFERRER可以给我的信息)
我在安装了cPanel的VPS上运行LAMP。我可以通过WHM编辑该域的DNS区域文件。
几分钟后,我的服务器支持中心,我终于获得通配符子域设置。
现在,当用户访问subdomain.example.com时,如果该子域通过cPanel显式设置,它将正常运行。如果该子域未被明确设置,那么它将被间接重定向到example.com,在那里我可以抓住他们使用的子域,并根据需要处理它(显示页面,重定向到子域或显示404错误)。
I've got a number of subdomains on one of my sites. When someone goes to a subdomain that doesn't exist, I want to redirect to a 404 page on my main domain.
noexist.example.com --> example.com/404.php?subdomain=noexist (or without the query string if HTTP_REFERRER can give me that info)
I'm running LAMP on a VPS with cPanel installed. I can edit the DNS Zone file for the domain via WHM.
After a few hours ticketing my server's support center, I finally got wildcard subdomains set up.
Now when a user goes to subdomain.example.com, if that subdomain was explicitly set up via cPanel, it will function appropriately. If that subdomain was not explicitly set up then it will be interally redirected to example.com, where I can grab the subdomain that they used and handle it as necessary (show a page, redirect to a subdomain, or show a 404 error).
这篇关于为不存在的子域创建错误页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!