TL;DR
When Apache’s mod_substitute processes very long single‑line payloads (common with WordPress’ admin-ajax.php and page builders like Elementor), it can error out with:
|
1 2 |
AH01328: Line too long, URI /blog/wp-admin/admin-ajax.php |
Fix by scoping your substitution filter and raising the line length limit with SubstituteMaxLineLength in a more specific <LocationMatch> for admin-ajax.php. In our case, a 100M limit resolved it.
Who is this for?
- WordPress admins using
mod_substitutefor URL rewrites/branding in responses. - Plesk/virtual host maintainers seeing
AH01328in error logs. - Anyone applying substitutions to
text/htmland JSON/JS/CSS where minified, single‑line responses are common.
Symptoms
- Editors intermittently fail to save or preview.
- AJAX actions (Elementor, WooCommerce, etc.) hang or error.
- Apache error log shows
AH01328: Line too longfor.../wp-admin/admin-ajax.php.
Why it happens (root cause)
mod_substitute works line‑by‑line. Minified assets or JSON responses can be a single, massive line that exceeds the module’s default maximum line length. When that happens, the filter aborts with AH01328.
The reliable fix
- **Keep your broad substitutions in a parent **
<Location>(or<Directory>), with a reasonable default line limit (e.g., 10–20 MB). - **Add a more specific
<LocationMatch>for **admin-ajax.phpand set a larger limit only there. This contains the risk and memory footprint.
Example configuration
Place the
LocationMatchafter your broader/blog/location so the more specific block takes precedence.
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# Broad scope for the blog section <Location /blog/> # Apply substitutions to the content types that actually need it AddOutputFilterByType SUBSTITUTE text/html # If you truly need to rewrite in assets, you can add these, but be aware of very long lines: # AddOutputFilterByType SUBSTITUTE text/css # AddOutputFilterByType SUBSTITUTE application/javascript # AddOutputFilterByType SUBSTITUTE application/json # Conservative default limit for most pages SubstituteMaxLineLength 20M # Your rewrite rules Substitute "s|www.acme.com|admin.acme.com|i" </Location> # Narrow override for gigantic single-line AJAX payloads <LocationMatch "^/blog/wp-admin/admin-ajax\.php$"> # Increase only where necessary to avoid global memory bloat SubstituteMaxLineLength 100M # Your rewrite rules Substitute "s|www.acme.com|admin.acme.com|i" </LocationMatch> |
Notes:
- Use explicit positive sizes (
k,M,Gsuffixes allowed). Empirically, setting0may be ignored depending on build/version; prefer a concrete size like100Mfor the AJAX endpoint. - Apache applies the most specific matching section. The
LocationMatchabove overrides the parent/blog/block.
Plesk specifics
- Put stanzas under the domain’s Apache & nginx Settings → Additional Apache directives, or in
/var/www/vhosts/system/<domain>/conf/vhost.conf. - After editing files under
.../conf/, run:
12plesk repair web -y
or reload Apache via systemd.
Verifying the change
- Config test
12apachectl -t - Reload
1234systemctl reload httpd # RHEL/CentOS/AlmaLinux# orsystemctl reload apache2 # Debian/Ubuntu - Hit the endpoint while tailing logs:
12tail -f /var/log/httpd/error_log # path may vary (/var/log/apache2/error.log) - Optional: temporarily raise verbosity to trace substitutions:
12LogLevel core:info substitute:trace1
Safety & performance considerations
- Scope narrowly. Large line limits increase per‑request memory usage. Keep big limits only on endpoints that need them.
- Filter only needed types. If you don’t need to rewrite JSON/JS/CSS, restrict to
text/htmlto avoid massive single‑line payloads. - Consider
qflag onSubstituterules (e.g.,...|iq) when rules are independent; this can avoid extra bucket merges and reduce CPU overhead.
Alternatives & fallbacks (if you still see errors)
- Raise the AJAX limit further (e.g.,
200M) if you can reproduce payloads exceeding 100 MB. - Split your substitutions: apply one set to HTML, and only the specific rule(s) required for JSON/JS in a separate, more targeted
<Location>. - Move heavy rewrites upstream (app‑level output buffering or CDN/edge workers) if transformations are complex.
Appendix: Useful commands
|
1 2 3 4 5 6 7 8 9 |
# Where is the vhost picking includes from? apachectl -V | egrep 'SERVER_CONFIG_FILE|HTTPD_ROOT' # Validate config then reload apachectl -t && systemctl reload httpd # Watch errors live journalctl -u httpd -f # or tail the error_log directly |
Have questions or want us to review your vhost? Reach out to Reliable Penguin — we’re happy to help.




