---
title: 'Mod_security settings for Wordpress 3.x'
url: 'https://maxwesten.nl/blog/articles/mod_security-settings-for-wordpress-3-x'
markdown: 'https://maxwesten.nl/blog/articles/mod_security-settings-for-wordpress-3-x.md'
date: '2012-01-01'
description: 'If you enable mod_security on your apache server and you install the base-rules, you''ll probably notice the WordPress blog isn''t functioning correct anymore. To fix this, you could add the following between the <vhost> tags in your vhost file that powers your blog: <LocationMatch "/"> SecRuleRemoveById 910006 # Google robot activity - Useful in someways but noisy for sites where you want them crawled'
taxonomy:
  category:
    - PHP
  tag:
    - Apache
    - Development
    - Mod_security
    - PHP
    - Wordpress
    - Work
  archives_month:
    - jan_2012
  archives_year:
    - '2012'
---

# Mod_security settings for Wordpress 3.x

[Home](https://maxwesten.nl/)  [Blog](https://maxwesten.nl/blog)  [Articles](https://maxwesten.nl/blog/articles)  Mod\_security settings for Wordpress 3.x 

## [ Mod\_security settings for Wordpress 3.x](https://maxwesten.nl/blog/articles/mod_security-settings-for-wordpress-3-x)

    1st Jan 2012   [Apache](https://maxwesten.nl/tag:Apache#body-wrapper) [Development](https://maxwesten.nl/tag:Development#body-wrapper) [Mod\_security](https://maxwesten.nl/tag:Mod_security#body-wrapper) [PHP](https://maxwesten.nl/tag:PHP#body-wrapper) [Wordpress](https://maxwesten.nl/tag:Wordpress#body-wrapper) [Work](https://maxwesten.nl/tag:Work#body-wrapper)  

If you enable [mod\_security](http://modsecurity.org/) on your apache server and you install the base-rules, you'll probably notice the WordPress blog isn't functioning correct anymore.

To fix this, you could add the following between the `<vhost>` tags in your vhost file that powers your blog:

```
<LocationMatch "/">
  SecRuleRemoveById 910006 # Google robot activity - Useful in someways but noisy for sites where you want them crawled
  SecRuleRemoveById 960015 # Request Missing an Accept Header -  Allow for Google Reader
</LocationMatch>

<LocationMatch "/wp-admin/post.php">
  SecRuleRemoveById 950006 # System Command Injection - Another rule that probably doesn't need to be disabled by everyone it stops .exe and various other extensions being passed in arguments.
</LocationMatch>

<LocationMatch "(/wp-admin/|/wp-login.php)">
  SecRuleRemoveById 950005 # Remote File Access Attempt - Probably no need to be disabled by everyone; it allows me putting /etc/ and other linux paths in posts.
  SecRuleRemoveById 950117 # Remote File Inclusion Attack - Disable to allow http:// to be passed in args
</LocationMatch>

<LocationMatch "(/wp-admin/options.php|/wp-admin/theme-editor.php|/wp-content/plugins/)">
  SecRuleRemoveById 950907 # System Command Injection
  SecRuleRemoveById 950005 # Remote File Access Attempt - Probably no need to be disabled by everyone; it allows me putting /etc/ and other linux paths in posts.
  SecRuleRemoveById 950006 # System Command Injection - Another rule that probably doesn't need to be disabled by everyone it stops .exe and various other extensions being passed in arguments.
  SecRuleRemoveById 959006 # SQL Injection Attack -
  SecRuleRemoveById 960008 # Request Missing a Host Header
  SecRuleRemoveById 960011 # GET or HEAD requests with bodies
  SecRuleRemoveById 960904 # Request Containing Content, but Missing Content-Type header

  SecRuleRemoveById phpids-17 # Detects JavaScript object properties and methods
  SecRuleRemoveById phpids-20 # Detects JavaScript language constructs
  SecRuleRemoveById phpids-21 # Detects very basic XSS probings
  SecRuleRemoveById phpids-30 # Detects common XSS concatenation patterns 1/2
  SecRuleRemoveById phpids-61 # Detects url injections and RFE attempts
</LocationMatch>

<LocationMatch "/wp-includes/">
  SecRuleRemoveById 950006 # System Command Injection - Another rule that probably doesn't need to be disabled by everyone it stops .exe and various other extensions being passed in arguments.
  SecRuleRemoveById 959006 # SQL Injection Attack -
  SecRuleRemoveById 960010 # Request content type is not allowed by policy - Allows for amongst other things spell check to work on admin area
  SecRuleRemoveById 960012 # Require Content-Length to be provided with every POST request - Same as above

  SecRuleRemoveById phpids-17 # Detects JavaScript object properties and methods
  SecRuleRemoveById phpids-20 # Detects JavaScript language constructs
  SecRuleRemoveById phpids-21 # Detects very basic XSS probings
  SecRuleRemoveById phpids-30 # Detects common XSS concatenation patterns 1/2
  SecRuleRemoveById phpids-61 # Detects url injections and RFE attempts
</LocationMatch>
```

There are a lot more exceptions, but these work in my situation at the moment. If you have good additional suggestions for mod\_security exceptions or idea’s on improving security within these rules for WordPress, contact me and I might update the post or write a follow-up….

Happy and safe sitebuilding…

 [ Previous Article](https://maxwesten.nl/blog/articles/goodbye-ibuildings-hi-rhinofly) [Next Article ](https://maxwesten.nl/blog/articles/birth-of-robin-westen)

#### Related Posts

- 100 

     [Easiest local development environment on OSX](https://maxwesten.nl/blog/articles/easiest-local-development-environment-on-osx "Easiest local development environment on OSX")
- 100 

     [The move to Statamic](https://maxwesten.nl/blog/articles/the-move-to-statamic "The move to Statamic")
- 100 

     [Setting up MockSMTP on OSX 10.7(Lion) for local PHP development](https://maxwesten.nl/blog/articles/setting-up-mocksmtp-on-osx-10-7lion-for-local-php-development "Setting up MockSMTP on OSX 10.7(Lion) for local PHP development")
- 100 

     [Developing in PHP with NetBeans 6.8](https://maxwesten.nl/blog/articles/developing-in-php-with-netbeans "Developing in PHP with NetBeans 6.8")
- 100 

     [Installing xDebug 2.0.4 or 2.1 on OSX](https://maxwesten.nl/blog/articles/installing-xdebug-204-or-21-on-osx "Installing xDebug 2.0.4 or 2.1 on OSX")

[←](https://xn--sr8hvo.ws/%F0%9F%92%95%F0%9F%8E%89%E2%A4%B5%EF%B8%8F/previous)An IndieWeb Webring 🕸💍 [→](https://xn--sr8hvo.ws/%F0%9F%92%95%F0%9F%8E%89%E2%A4%B5%EF%B8%8F/next)

---

## Navigation

- Parent: [Articles](https://maxwesten.nl/blog/articles.md)
- Previous: [Birth of Robin Westen](https://maxwesten.nl/blog/articles/birth-of-robin-westen.md)
- Next: [Goodbye Ibuildings, Hi Rhinofly](https://maxwesten.nl/blog/articles/goodbye-ibuildings-hi-rhinofly.md)
