A colleague showed me how to set up a local environment for testing. This allows us to test a rewrite rule without risking downtime on the production environment.
Edit: See the Rewrite rule witch for a quick start with rewrite rules.
Modify your hosts file
- Add 127.0.0.1 test-rewrite to your /etc/hosts file
Set up apache
- Install Apache locally, if you hadn't already. :)
- Add an Apache config file test to /etc/apache2/sites-available, which looks like
# The rewrite rule under scrutiny
# Assumes your Zope is running on port 8080
RewriteRule ^/(.*) http://127.0.0.1:8080/VirtualHostBase/http/test-rewrite:80/VirtualHostRoot/$1 [P,L,NC]
CustomLog /var/log/apache2/test-rewriterule.log combined
- Enable modules proxy, rewrite, proxy-http (using a2enmod)
- In proxy.conf, set "Allow from all"
- Enable the new config: a2ensite test
- Modify /etc/apache2/sites-available/default so it begins with
- Run apache2ctl -t and apache2ctl -S
- Run a tail -f on /var/log/apache2/rewrite.log
- Tinker on your rewrite rule, and restart apache (/etc/init.d/apache2 restart) after modifications.
- Go to http://test-rewrite and watch the log to see what happens