1

I have a simple web app that resides on an web server. The setup is Apache, PHP, MySQL, Windows Server 2012 R2. The server resides on our internal network behind a corporate firewall.

The web app is only accessible on our internal network via the URL www.webapp.example.com

When someone attempts to access this URL externally (i.e at home) they receive a generic error message in their client browser, such as with Chrome in the following screenshot;

enter image description here

My question, is there any way I can create a custom error page so that when someone attempts to access www.webapp.example.com outside our network they will see a custom error, something simple like;

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

We do own www.example.com and it's publically accessible over the internet, however the subdomain www.webapp.example.com is only accessible internally.

I'm not sure if this is something I have to configure on the web server, the .htaccess file, or elsewhere? Ideally I only want to allow access for a range of IP's (123.456.xxx.xxx), all others should see the custom error page.

Quite new to custom error handling so any help is appreciated

jonboy
  • 2,729
  • 6
  • 37
  • 77

1 Answers1

1

You can use RewriteCond and %{REMOTE_HOST} to target everything but your internal ip addresses:

<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>
Community
  • 1
  • 1
David Duponchel
  • 3,959
  • 3
  • 28
  • 36