Better way to test .htaccess file

10,577

There are a few web based testers available to use, unfortunately, these don't always understand all the syntax to accurately check how it works on a real site.

One web based one I like to use is this online tester from Made with Love; http://htaccess.madewithlove.be/

It doesn't understand a few items such as %{REQUEST_FILENAME} but for general testing I think it should do the job for you. You copy your code into the box, and you can also submit a url to see what it will rewrite to. If you just want to check syntax errors there are a few web tools available as well.

Using web based tools are great for an overall check, but you can't really be sure how it affects a real site until you upload it either to a dev version of the real thing.

Just recently I've edited a htaccess file, which showed no syntax errors and worked as expected on the tester, which did not work at all on the real site. Site settings may have an impact and all other things which will not show on a web tool.

Share:
10,577
Vyshnavi Samudrala
Author by

Vyshnavi Samudrala

Updated on June 04, 2022

Comments

  • Vyshnavi Samudrala
    Vyshnavi Samudrala almost 2 years

    I don't have much experience with htaccess rules, some of them are working but when I add a new rule or remove one, how do I test them?? I cannot test it on the actual server. Even in my localhost, I won't be able to test some like https rules, www and other stuff.

    I can test the rest of url patterns but when I add the www and https rules along with the tested ones on the live server, it gives an error and then I continue testing them on the live server.

    Is there a way to test them without using the actual server and not create another server for testing those rules. Something like a htaccess rule checker or something!?

    • lkdhruw
      lkdhruw almost 7 years
      You can test everything on the local server as well. If you don't want to change anything in the root folder then create a virtual host on the local server and test everything there.
  • MrWhite
    MrWhite almost 2 years
    If you get a 500 error, you need to check your server's error log for the details of that error. In this case, it's likely that mod_headers was not installed.