How to debug your htaccess rewrite rules
Posted in link
Tags :I was cleaning up my .htaccess
file in an attempt to simplify it, and clean up a bunch of legacy rewrites, when ran into a regex issue that needed testing and validation.
Previously, I use to edit and test the rules locally or on a staging instance, but yesterday I discovered quite by chance a brilliant online tool called htaccess tester by madewithlove that enables realtime testing of sets of rules.
Enter a URL you wish to test, paste in your set of rules (or all your .htaccess file), click on test and check if the output URL matches your expectations.
If it doesn’t, the debugging info pane walks you through your rules one by one indicating if the condition was met or not. Server variables can be set to simulate different contexts.
This tool shines by its simplicity and usefulness. It not only did it saved me time, it also helped me better understand how and when (and why) certain of my more obscure rules were triggered or not.
If you meddle in Apache’s mod_rewrite at all, this tool is a game changer.