gpt4 book ai didi

php - 自定义错误页面Intranet子域

转载 作者:行者123 更新时间:2023-12-03 07:53:40 25 4
gpt4 key购买 nike

我有一个位于Web服务器上的简单Web应用程序。设置为Apache,PHP,MySQL,Windows Server 2012 R2。该服务器位于公司防火墙后面的内部网络中。

仅可通过URL www.webapp.example.com在内部网络上访问该Web应用程序

当有人尝试从外部(即在家)访问此URL时,他们会在其客户端浏览器中收到一条通用错误消息,例如以下屏幕快照中的Chrome;

enter image description here

我的问题是,有什么方法可以创建自定义错误页面,以便当有人尝试访问我们网络之外的www.webapp.example.com时,他们会看到自定义错误,类似以下内容:

This application is only available within the www.example.con network



我们拥有www.example.com,并且可以通过Internet公开访问,但是子域名www.webapp.example.com只能在内部访问。

我不确定这是否是我必须在Web服务器,.htaccess文件或其他位置上配置的东西吗?理想情况下,我只希望允许访问一定范围的IP(123.456.xxx.xxx),所有其他IP都应看到自定义错误页面。

自定义错误处理非常新,因此可以提供任何帮助

最佳答案

您可以使用RewriteCond and %{REMOTE_HOST}定位除内部ip地址以外的所有内容:

<VirtualHost *:80>
ServerName www.webapp.example.com

RewriteEngine On
RewriteCond %{REMOTE_HOST} !^123\.456\..*
RewriteRule $ /no_public_access.html [L]

Alias /no_public_access.html /path/to/no_public_access.html

# …
</VirtualHost>

关于php - 自定义错误页面Intranet子域,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40718242/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com