Posts Tagged ‘Wordpress’

Apache mod_security settings for WordPress and ModX

Monday, January 7, 2013 posted by Till

If you use the apache mod_security module on your apache server, you might encounter wrong 403 errors for several URL’s of the cms systems. Here are some exception rules to avoid that:

For WordPress Blogs

<locationmatch "/wp-admin/admin-ajax.php">
SecRuleRemoveById 300013
SecRuleRemoveById 300015
SecRuleRemoveById 300016
SecRuleRemoveById 300017
</locationmatch>

<locationmatch "/wp-admin/page.php">
SecRuleRemoveById 300013
SecRuleRemoveById 300015
SecRuleRemoveById 300016
SecRuleRemoveById 300017
</locationmatch>

<locationmatch "/wp-admin/post.php">
SecRuleRemoveById 300013
SecRuleRemoveById 300015
SecRuleRemoveById 300016
SecRuleRemoveById 300017
</locationmatch>

For the ModX CMS

<LocationMatch "/manager/index.php">
SecRuleRemoveById 300016
</LocationMatch>

<LocationMatch “/connectors/resource/index.php”>
SecRuleRemoveById 300013 300014 300015 300016
</LocationMatch>

<LocationMatch “/connectors/element/tv.php”>
SecRuleRemoveById 300013 300016
</LocationMatch>

Add these rules inside the vhost file of the website. If you use ISPConfig to manage the server, then add the rules in the apache directives field of the website settings in ispconfig.

Many thanks to PlanetFox for providing the rules.

How to avoid that wordpress replaces — with – in HTML

Wednesday, August 5, 2009 posted by Till

If you run a blog that covers topics from Linux / Unix like we here at FAQforge and you include Linux shell commands in a wordpress post, you might have noticed that WordPress replaces the char combination “–” with &#8211; in the HTML sources. But the replacement &#8211; is displayed by the browser as “-” and not “–”. So if someone copys your shell command examples to execute them, they will not work. To fix this behaviour, edit the file wp-includes/formatting.php in wordpress and replace the lines 55 and 56:

$static_characters = array_merge(array(‘—’, ‘ — ‘, ‘–’, ‘ – ‘, ‘xn&#8211;’, ‘…’, ‘“’, ‘\’s', ‘\’\”, ‘ ™’), $cockney);
$static_replacements = array_merge(array(‘&#8212;’, ‘ &#8212; ‘, ‘&#8211;’, ‘ &#8211; ‘, ‘xn--’, ‘&#8230;’, $opening_quote, ‘&#8217;s’, $closing_quote, ‘ &#8482;’), $cockneyreplace);

with:

$static_characters = array_merge(array(‘—’, ‘ — ‘, ‘xn&#8211;’, ‘…’, ‘“’, ‘\’s', ‘\’\”, ‘ ™’), $cockney);
$static_replacements = array_merge(array(‘&#8212;’, ‘ &#8212; ‘, ‘xn--’, ‘&#8230;’, $opening_quote, ‘&#8217;s’, $closing_quote, ‘ &#8482;’), $cockneyreplace);