Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a build script (Perl) that modifies the .htaccess file when I deploy my applications. As a double-check, I'd like to be able to perform some sort of syntax checking on the created .htaccess file.

I am familiar with the idea of using apachectl -t however, I am in a shared hosting environment and because of file access restrictions I cannot read certain configuration files specified by the sysadmins. Apachectl simply will not work in this regard.

Ideas or suggestions welcome.

share|improve this question
But even if you could run apachectl -t it is used for virtualhosts only it would not serve to your needs. My best guess would be that you gona need to make your own validator ... perhaps asking in the will get you a lead of how to go thru about this. At any rate this is more programming related from what i see. – Prix Aug 28 '10 at 17:37

There is no native .htaccess validator. If a third party tool exists, I am not sure if I would trust it. Since it is a script that modifies the file, you should be able to code the validation within your script.

You can also include testing and verification processes for your deployment, which would help reduce mistakes.

share|improve this answer
This would be part of the testing..... – Danny Mar 23 '10 at 3:53

Here two useful, free services:

This one lets you upload an .htaccess file for validation.
This one lets you paste the contents of an .htaccess file into a textbox for validation.

share|improve this answer
Welcome to Server Fault! Whilst this may theoretically answer the question, it would be preferable to include the essential parts of the answer here, and provide the link for reference. – Scott Pack Aug 26 '12 at 0:01
Also, a link and run like that does generally tend to get flagged as spam, so next time, it may be wise to consider adding some content and context into your post. – HopelessN00b Aug 26 '12 at 3:09

Using cool Text Editors like Coda for Mac or TextMate for Mac or maybe Notepad++ for PC, you can enable syntax highlighting, which might not be perfect, but will be helpful. .htaccess is written in Per, so just turn on Syntax Highlighting for Perl!

share|improve this answer
.htaccess is not written in Perl, not by a longshot. – Ken Williams Feb 25 at 5:22

The most reliable syntax checker is Apache itself.

If you can handle 500ms of possible downtime (the time it takes to make an http request to localhost, very approximately) then do this:

  1. Make a backup of the current htaccess file
  2. Replace the current htaccess file with the file to be tested
  3. Make a request to the server, for example "curl localhost"
  4. If the curl is not successful, place the backup back
share|improve this answer
In general, functionality checks like these should be a standard part of your deployment environment. Good stuff! – womble Sep 10 '15 at 3:52

You can simply use Notepad++ for syntax checking.

Silas Brill has been gracious enough to create a custom language for htaccess files and share it here.

Just go to View -> User-Defined-Dialogue -> Import

and restart Notepad++. You should be able to see the new language under the Language option.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.