What is SubstituteMaxLineLength in my htaccess file
SubstituteMaxLineLength controls the limit for maximin line length of an HTML GET/POST command. It supports only numbers and can be suffixed with a single letter b, B, k, K, m, M, g, G to provide the size in bytes, kilobytes, megabytes or gigabytes respectively. Without a letter suffix the default value is bytes. The command was first added to Apache in version 2.4.11 and will default to 1M if not set.
Microsoft has a similar attribute called maxRequestLength found in either the web.config or the IIS Manager settings.
Why is this important
In the early days of the Internet this was used to prevent denial of service attacks. In today’s Internet this presents problems and several errors can be fixed by modifying this attribute to a larger value. Below is a sample of know possible errors when the value is set to small.
Possible errors:
- Backend pages appearing blank
- Site and Network Timeout Errors
- AH01328: Line too long
- Corrupt download errors (value must be larger than your largest download, recommend using FTP)
- Files will not download
- Bad Gateway when viewing Frontend pages
- ERR_HTTP2_PROTOCOL_ERROR
- ERR_EMPTY_RESPONSE
- WordPress customizer shows only a white page (common GoDaddy issue)
- WordPress editor shows no content when editing a page.
- WordPress Visual Composer does not display.
Why WordPress is sensitive to SubstituteMaxLineLength’s value
WordPress uses themes and plugs to extend its features and functions. Often when activating multiple plugins one of the blank page issues appears. The reason for this each plugin typically adds code to admin pages in the form of JavaScript especially any editor pages whether its the classic or Gutenberg version.
The worst offenders are large functionality plugins like WooCommerce or Page Builders like Beaver Builder, Divi Builder, Elementor, Visual Composer, etc. This list isn’t exclusive to these plugins but are the most common offenders.
WordPress Themes often hide that they are using a white-label version of a page builder. Additionally a theme’s Option or Settings page that’s outside of the customizer settings are build using JavaScript and could display blank or timeout when saving changes.
How to fix
The easiest fix it to increase the limit to 10M. Add the code below to your htacess file in your root directory. Place the code at the top of your htaccess file. You must have the substitute module enabled for it to work.
<IfModule mod_substitute.c>
SubstituteMaxLineLength 10M
</IfModule>
You can also limit which directories make use of the value for download and upload directories for a site by wrapping the command in directive targeting the directory. Example below:
<If "%{REQUEST_URI} =~ m#^/download/$#">
Header set Cache-Control "max-age=0, no-cache, no-store, must-revalidate"
<IfModule mod_substitute.c>
SubstituteMaxLineLength 50M
</IfModule>
</If>
Change the /download/ to your path that you need to manipulate to allow for large file downloads and uploads. Please consider moving large files to an FTP server or use an application to manage large file downloads.
Why not set it to 1000G
Remember the setting is to help prevent denial of service (DoS) attacks. Setting the value to large could cause performance issue.
Did you get a clue?
If you got a clue and want to thank me, then visit the thank me page. It’s the best way to keep me publishing articles and keeping this site operation.
This site uses affiliate links. When you go to another site from here the link typically will have an affiliate code attached to it. Your actions on that site may earn a small commission for me. Read our affiliate link policy for more details.
{fin}