Skip Navigation

Ignore Directories in mod_rewrite

A quick piece of code for you. If you are using mod_rewrite and creating RewriteRules for a website that emulate a directory structure, you might happen across the same problem I've had. If you have actual, real folders on the site as well, you don't want requests for items in those folders to be rewritten. You need a way to prevent the RewriteRule(s) matching the real folders. The easiest way to do this is (I think) by adding a RewriteRule for each of the real folders, like the below. This rule will match any request to those folders and prevent it being rewritten later in the set of rules.

RewriteRule ^folder_name/.*$ - [PT]

Latest Article

Nine More Ways To Improve Your Website Conversion Rate

The second article in the "Improve Your Website Conversion Rate" series. Learned the lessons of part 1? Here are nine more ways to improve your conversion rate.

Latest Cheat Sheet

Python Cheat Sheet

The Python Cheat Sheet, a quick reference guide for the Python programming language.