How to test Apache mod_rewrite

You can check the configuration files to see if it is enabled, but we want to test if it is working. That’s Easy!

  1. Create two files
    1. test1.html
      1. The Apache mod_rewrite is not working
    2. test2.html
      1. The Apache mod_rewrite IS working - Congratulations!
  2. Edit the .htaccess file, or create one if it does not already exist in the root of the web site directory you are testing
    1. Add these lines
      1. RewriteEngine On
      2. RewriteRule ^test1.html$ /test2.html [R=301]
  3. Copy the two html files to your website
  4. Run http://example.com/test1.html in your browser
  5. Test complete
  6. If apache automatically produces the working text, then everything is working correctly and mod_rewrite is installed and working properly

Popularity: 1%

Leave a Reply

You must be logged in to post a comment.