The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Modifiying 406 error messages triggered by Mod Security

Discussion in 'Security' started by thobarn, Jan 10, 2009.

  1. thobarn

    thobarn Well-Known Member

    Joined:
    Apr 25, 2008
    Messages:
    153
    Likes Received:
    1
    Trophy Points:
    18
    Location:
    sanctum sanctorum
    How can I modify the 406 returned by Mod Security triggers?

    I am able to modify most other error documents on per domain basis by placing ErrorDocument directive to respective .htaccess files, and they work with the exception of 406 errors.

    For example, in domain dummy.com docroot I have the following in .htaccess:
    ...
    ErrorDocument 404 /[path_to_doc] (this works)
    ErrorDocument 406 /[path_to_doc] (this does not)
    ...

    When Mod Security triggers on dummy.com, a 406 is returned but it is not the customised 406 document given by ErrorDocument directive above :confused:


    Thanks
     
  2. rhenderson

    rhenderson Well-Known Member

    Joined:
    Apr 21, 2005
    Messages:
    785
    Likes Received:
    0
    Trophy Points:
    16
    Location:
    Oklahoma
    cPanel Access Level:
    Root Administrator
    Have you just tried 406.shtml in the root public_html? Just a thought.
     
  3. markhard

    markhard Well-Known Member

    Joined:
    Apr 22, 2004
    Messages:
    250
    Likes Received:
    0
    Trophy Points:
    16
    well you don't want to copy the same file over and over again on all hosting account right?
     
  4. SuperBaby

    SuperBaby Well-Known Member

    Joined:
    Nov 27, 2003
    Messages:
    331
    Likes Received:
    0
    Trophy Points:
    16
    Location:
    Thailand
    cPanel Access Level:
    Website Owner
    Twitter:
    If it is for just one or two accounts, just edit look at the mod_security log which 406 page it is directing to. Then modify that page. This way, you do not need to edit your htaccess to include ErrorDocument 406 /[path_to_doc].
     
  5. rhenderson

    rhenderson Well-Known Member

    Joined:
    Apr 21, 2005
    Messages:
    785
    Likes Received:
    0
    Trophy Points:
    16
    Location:
    Oklahoma
    cPanel Access Level:
    Root Administrator
    I appeared by the poster (since they were talking about an .htaccess file) this was for one account, but I could be wrong.
     
  6. thobarn

    thobarn Well-Known Member

    Joined:
    Apr 25, 2008
    Messages:
    153
    Likes Received:
    1
    Trophy Points:
    18
    Location:
    sanctum sanctorum
    Solved

    Thanks for your replies. It turns out that it was the interaction with mod security. Any rule triggered in Phase 1 was causing the main server error documents to be served and not the ones defined in .httaccess in each virtual host :)p because during P1 URL transformation is not yet performed by apache). Moving those rules to phase 2 resolved the issue. Thanks again.
     
Loading...
Similar Threads - Modifiying 406 error
  1. Mahmoud Alesali
    Replies:
    3
    Views:
    432

Share This Page