Suppress admin email on django ALLOWED_HOSTS exception

前端 未结 6 2128
心在旅途
心在旅途 2020-12-14 18:08

Since the introduction of the ALLOWED_HOSTS setting in django 1.4.4, I get a lot of django error emails to my admin address for exceptions caused by some silly spider lookin

6条回答
  •  别那么骄傲
    2020-12-14 18:47

    So I typically prefer to just redirect all unmatched vhosts to a single vhost. this is done with a simple addition to the apache.conf file...

    
        RedirectMatch ^/?(.*) http://www.example.com/$1
    
    

    The example above would result in a request to any unmatched vhost to redirect to http://www.example.com, while retaining the path component properly.

    This also has the added advantage of correcting the case where a user is following an invalid request or some such thing.

提交回复
热议问题