Force Google SafeSearch in DansGuardian

I have been trying to get DansGuardian (now called E2Guardian) to force everyone to go through Google SafeSearch when they are searching using any Google service (images, web search, code, whatever). DansGuardian, as of, includes the ability to run Regular Expressions on urls, body content, and headers.

Google allows you to force safesearch by adding the option safe=on or safe=active to the url. In addition, Google has an undocumented feature that allows you to set “VerySafeSearch” by adding the safe=vss option. What I am trying to do is use the regexp url function to add this option.

DansGuardian has an example included that should force VSS on image search. Sadly, it does not work. Here is what I came up with:


These two lines need to be put into the file /etc/dansguardian/lists/urlregexplist. This should force Google VSS on all Google search services (except youtube) in all country codes (e.g.,,

There are two parts to this. The first line removes the option that disables safe search: safe=off. The second line adds the safe=vss option.

The basic replacement syntax is this:
Simply, what is found between the first set of quotes is replaced by what is found in the second. For more details about regular expressions and danguardian see the following sites:
Perl Regular Expressions
Regular Expressions in Perl
Regular Expressions in DansGuardian

If anyone finds a way to get around this, please comment.

7 Responses to “Force Google SafeSearch in DansGuardian”

  1. Anonymous


    The example supplied with Dansguardian forces image searches to be safe, and works fine for that. To force Google to use safe mode for normal searches try this:

    # … remove ‘safe=…’
    # … and add ‘safe=vss’

    This works fine for me …


  2. Rob

    Seems to be a loophole if you go to google image search, type something risky with strict filtering on then search, then turn safesearch off and it will auto fill the page with results you wouldn’t have been able to see if you had hit search.

  3. Terry

    To do something similar for youtube.

    Add this to bannedregexpheaderlist

    Adding this to exceptionregexpurllist will allow you to go to the youtube home page to turn safety mode on.$*action_get_safetymode_picker.*$*$\?.*$


  4. William Johnston

    I haven’t looked at any solutions for this. The posted solution is definitely broken, and so much of Google is AJAX these days, I am not sure if there is a good solution. I hope to take another look at this some day, perhaps this summer.


Leave a Reply

  • (will not be published)

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>