Welcome to WebmasterWorld Guest from 54.166.46.226

Forum Moderators: Ocean10000 & incrediBILL & phranque

Message Too Old, No Replies

htaccess validator

help with .htaccess

   
11:43 pm on Mar 16, 2012 (gmt 0)



Noticed a few people asking about this. I was asking the same thing "Is there a .htaccess validation tool?" - I found one so I thought I'd register and provide the address. Gives report of errors (according to?). I learned something from it.

http://www.lyxx.com/freestuff/002.html
12:07 am on Mar 17, 2012 (gmt 0)

WebmasterWorld Senior Member g1smd is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month



It's easily possible to write syntactically correct code that does something other than what you intended under some input conditions, so don't rely on a tool such as this.

Hmm. Just submitted a production htaccess file from one of my sites and it reports more than 200 errors and says they'll fix it for 150 dollars. Not impressed so far. The results don't say what the problem in the code is supposed to be.
12:24 am on Mar 17, 2012 (gmt 0)



"...results don't say what the problem in the code is supposed to be"

Right, I mentioned the according to (?). Did you know whether the report was valid and why?

I noticed it didn't like commenting with more than one hash mark ###

I was unsure about the results but it gave me something to look at.
12:34 am on Mar 17, 2012 (gmt 0)

WebmasterWorld Senior Member g1smd is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month



There's no errors in any of the code I submitted as far as I know.

For this partcular test, I submitted version 84 from a live site.
2:28 am on Mar 17, 2012 (gmt 0)

WebmasterWorld Senior Member 5+ Year Member



it reports more than 200 errors

If that were true I'd be amazed if your site was still online.

and says they'll fix it for 150 dollars

It would be funny to see them turn up here and ask how to do it.

...
4:02 am on Mar 17, 2012 (gmt 0)

WebmasterWorld Senior Member lucy24 is a WebmasterWorld Top Contributor of All Time Top Contributors Of The Month



It would be funny to see them turn up here and ask how to do it.

Well, we do get an awful lot of one-post wonders :)

I noticed it didn't like commenting with more than one hash mark ###

I think what it may react to is non-initial hashes. In addition to sets of three, it didn't like this line:

# Deny from nn.nn.0.0/15 # {name here}, trial unblock

That's actually a reasonable thing to worry about-- except that it should exclude lines that start with a # since nothing else matters after that.

I spent a long time poring over their objections and finally got most of them identified, but there remains one I can't for the life of me figure out. I even tried resubmitting the same htaccess to make sure they weren't flagging things at random :)

(50) = They don't approve of %{REMOTE_ADDR} followed by anything other than a complete, literal string, anchored at both ends, with no variables (pipes or bracketed groups).

(159) = They don't like \w or \d in Rules, though they don't mind them in Conditions.

(30) = I have no clue. This is an error:
RewriteCond %{HTTP_USER_AGENT} MSIE\ [56]\.\d

This is not:
RewriteCond %{HTTP_USER_AGENT} MSIE\ 7\.0;\ Windows\ NT\ [56]\.\d

No, I did not get those two backward. I think a chorus of "wtf?!" is called for ;)
3:54 pm on Mar 17, 2012 (gmt 0)



One of the reasons I was looking for some type of checker or validation tool was rules that were working seemed to stop working. This:

"RewriteCond %{HTTP_USER_AGENT} MSIE\ [56]\.\d" ( from which member got the error report )

or specifically in my case this:

"RewriteCond %{HTTP_USER_AGENT} MSIE\ ([23456])\.[NC]
RewriteRule .* - [F,L]" (I had to dig this up it may not be exact syntax)

is one of those things that stopped working. I started seeing a bunch of bots using IE6 waltzing right through. I hadn't changed anything...

I put this in instead and it worked.

Deny from env=bad_bot
BrowserMatchNoCase "MSIE 6\.0" bad_bot
BrowserMatchNoCase "MSIE 5\.0" bad_bot

I say this because errors in htaccess file don't always cause 500. They may just not do what I think there supposed to do.

I don't know enough to write my own rules and conditions. Reading at apache site makes my head hurt. I tried out a lot of stuff from authors and lots of it didn't work (for me).

I did continue looking and found the syntax documentation but got comafied after 2 or 3 minutes. Seems if someone took the time to write the tool they'd use the official rules to test against. I also looked into the site and their ip and saw no bad reports.

This still may be helpful to some people at some level as long as caution and common sense are put into practice.
7:48 pm on Mar 17, 2012 (gmt 0)

WebmasterWorld Senior Member g1smd is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month



In
\.[NC]
you need a space between
\.
and
[NC]


[F,L]
should be
[F]


Where's the explanation of what the supposed error for each line is?
12:32 am on Mar 18, 2012 (gmt 0)

WebmasterWorld Senior Member lucy24 is a WebmasterWorld Top Contributor of All Time Top Contributors Of The Month



Where's the explanation of what the supposed error for each line is?

Search me. I guess that's what you have to pay $149.95 for. You may have noticed that the site (backtracking to /freestuff/) says "over 25 basic syntax errors" while the three I picked up are called 30, 50 and 159.