Title: Apache error: preg_match(): Compilation failed
Last modified: December 25, 2023

---

# Apache error: preg_match(): Compilation failed

 *  Resolved [mrgrooves](https://wordpress.org/support/users/mrgrooves/)
 * (@mrgrooves)
 * [2 years, 5 months ago](https://wordpress.org/support/topic/apache-error-preg_match-compilation-failed/)
 * Hi Emre,
 * Looking at my website log, I came across an Apache error for your plugin. It 
   says:
   AH01071: Got error ‘PHP message: PHP Warning: preg_match(): Compilation
   failed: quantifier does not follow a repeatable item at offset 0 in /var/www/
   vhosts/booinstruments.us/httpdocs/library/wp-content/plugins/wp-fastest-cache/
   inc/cache.php on line 624’The line in question in the plugin is this: if(preg_match(“/”.
   $value->content.”/i”, $request_url)){
 * Please let me know if you need additional info from me to resolve the issue.
 * Thank you.

Viewing 15 replies - 1 through 15 (of 17 total)

1 [2](https://wordpress.org/support/topic/apache-error-preg_match-compilation-failed/page/2/?output_format=md)
[→](https://wordpress.org/support/topic/apache-error-preg_match-compilation-failed/page/2/?output_format=md)

 *  Plugin Author [Emre Vona](https://wordpress.org/support/users/emrevona/)
 * (@emrevona)
 * [2 years, 5 months ago](https://wordpress.org/support/topic/apache-error-preg_match-compilation-failed/#post-17300854)
 * How often does this warning appear?
 *  Thread Starter [mrgrooves](https://wordpress.org/support/users/mrgrooves/)
 * (@mrgrooves)
 * [2 years, 5 months ago](https://wordpress.org/support/topic/apache-error-preg_match-compilation-failed/#post-17300859)
 * Every couple of minutes. I’ve gone back only to yesterday through the log and
   there are hundreds of such warnings in that time span.
 *  Thread Starter [mrgrooves](https://wordpress.org/support/users/mrgrooves/)
 * (@mrgrooves)
 * [2 years, 5 months ago](https://wordpress.org/support/topic/apache-error-preg_match-compilation-failed/#post-17300860)
 * According to ChatGPT (if it is of any help):
 * **Potential Solution:**
    - The problem might be caused by the contents of `$value->content` not being
      a properly formatted regex pattern. It’s possible that `$value->content` contains
      special regex characters that need to be escaped, or it forms an invalid regex
      pattern.
    - To fix this, you can use `preg_quote()` to escape any special regex characters
      in `$value->content`. Here’s the modified line of code:
 * `if(preg_match("/".preg_quote($value->content, '/')."/i", $request_url)){`
    - `preg_quote()` will escape any regex special characters in `$value->content`,
      making it safe to use in `preg_match()`. The second parameter `'/`‘ is to 
      escape any slashes since your regex pattern is delimited by slashes.
 *  Plugin Author [Emre Vona](https://wordpress.org/support/users/emrevona/)
 * (@emrevona)
 * [2 years, 5 months ago](https://wordpress.org/support/topic/apache-error-preg_match-compilation-failed/#post-17300862)
 * can you take a screenshot of the exclude rules and share with me please?
 *  Thread Starter [mrgrooves](https://wordpress.org/support/users/mrgrooves/)
 * (@mrgrooves)
 * [2 years, 5 months ago](https://wordpress.org/support/topic/apache-error-preg_match-compilation-failed/#post-17300864)
 * ![](https://lh3.googleusercontent.com/pw/ABLVV87j0fbiZVPhIzT5IRlshbx4gqwVFYP9ZzgHP6iNqhh_jqivkQtR6b712zvwNZLUboSKhWgVP7fQMrrnZmX9DH-
   GaMyN56iZqB2NGA69nabr6i2H8WDAspp9_GNZwH0yMneNdR47cLVZdYPSXIE_FdGxGfZX8VB-BBBHOiaM1c6C8XSlVwuwhk-
   Z2xZt8mP2aFHUy05TUEQA8TgcBzo5UBgm9lGcVr02YAnyglAex6uWuJAkUIct2DHep0cYRJat6lneK-
   8EbYSUIv5oQUBkVQf-qbx5c-RKu2mLfu7_jfYVbUWF40WI-PFhCdS5rucr29wzBcIVXaUqvpLplsWDaipIMchduqNJ6kItiCm6sTllb4bnF58iHH6jmjV6VcXOeB8_SnF_F_dYSQEmdYJuCcYJqITF6VJ-
   IzBQgsVZ8XAKn7Gn1l76upbjhg0XVVyWJx22CxlMWMWM2vjv7gbzC2kAeT79BV-TKn3juVd2nfnqZwBY4arz8sL0yBYwdVEvJ9KBgePmUH-
   1iupbbGH4xfZdvlEsENcn8k0Bzs90kEUP7esfwrba37ylBGZwfpPMWDOeDCoWY7VDGOdmbnKSXK5tVxXC8KFMK__WSar83byMUzjZRqdGrg3YhI56zoDnS48eMD4T0OJbeYGZtvf1fsM93MRYINK3ESSHaEcsV89JS0-
   CuAwBX0tHPT_QinY5xqRbE8231LVgXsTgiMMvDvwi1iwKWFNDOUbN-5drKHfHW_8U5pJ_35wNfWzMJC5ivuG2-
   ZX2UHaZInqKBFGMs15v30xj9dd3WUXxJFWSp32WYaTz0LySO7DdZka1DO0sDfqso9PgPJDSgs4foToLTibNnlcvKKi8n0WFdndlbnvV5Gni1Wgazo283bNsAvv9gdg
   =w1140-h1404-s-no-gm?authuser=0)
 * Here.
 *  Plugin Author [Emre Vona](https://wordpress.org/support/users/emrevona/)
 * (@emrevona)
 * [2 years, 5 months ago](https://wordpress.org/support/topic/apache-error-preg_match-compilation-failed/#post-17300865)
 * can you remove the “regex” one please?
 *  Thread Starter [mrgrooves](https://wordpress.org/support/users/mrgrooves/)
 * (@mrgrooves)
 * [2 years, 5 months ago](https://wordpress.org/support/topic/apache-error-preg_match-compilation-failed/#post-17300868)
 * Done. I added the rule like this now. It should work the same, but without the
   error, right?
 * ![](https://lh3.googleusercontent.com/pw/ABLVV8420rCAqYWuHo42pzP3BwsAuq7wNt_C0Q-
   P3ooNAvTXcF3--KQV4Ffzm6gxzLMVIZ7lRs1ZhL6PXFp7j4tC-vwBFjxtfm6ODhroaJWXdZaYlhK7Lf-
   WDmEKcmoFAqIoCK1slqrTxoA8c2eGj66zBg_mDHI2aDawS1ue8sS3DFJlpHlPpBNuKq7CEpd8u_vVUXK-
   woAkJQ5PILN718kjcnqoF8Vz91q7r79UGaSIxwjfAW3AuQeEVMfI2bzBbitl-9jg43zxdamFEMIZCOo2PpaZ6e16IBolCj5UKa_C6daQyTfhcw_14-
   Bqt2AbXFxkyHletNLrzA4RrooYl64rEAmQMnGZ0dCBvBpHST_du1IxJr-Mgx_CtsVCTO9CAd-P25CGZKR659Ctr4C8jCiMF1AXmcYddpSvcG03Bhj_njePR2jzU8TESpPqiJeWhvsZRgA2ePFLrXttaLqxk9Ay7SXDGSdn4wXlBTMgaoGTuNGOUIlvSmUssz4qFcIfTZdD9B8bwfkm143EufXCwAj224yX0cNOeDDnVqXhF_XPgZs_7U6nRmpmWFGxSkOX_8-
   LeBGJZkcZrTcfafTH-UYpA31K6cURVcVT5mik_BeUQEQ0qGa08kPPlzPU-XUHRls_KRfjnlya9I6bIt6jjbWFLbYBnP12ycrynydJs5xJRDNpSoFfhKCw5lBsDwmHqy0ieAqa4z-
   5nvYKZT57mOudqRlakVzGQDUaPW3VjQwnmendGAsWqbfHpi44reOFARzTQTE77Go8c8MDq9ODvHP7VLu2ZYHea8EpuOb7toQOOkWRI3JTOiC6SXsdKvea8RMe5uHJt9GvWa917wHIsOBicqjpLlP9Ee5qHDr-
   xX4TAxo0r9VyAXoD9L-Ifx2uMeBW0cU=w1158-h1450-s-no-gm?authuser=0)
 *  Plugin Author [Emre Vona](https://wordpress.org/support/users/emrevona/)
 * (@emrevona)
 * [2 years, 5 months ago](https://wordpress.org/support/topic/apache-error-preg_match-compilation-failed/#post-17300874)
 * No need to add such a rule, as URLs containing a query string are excluded automatically.
 *  Thread Starter [mrgrooves](https://wordpress.org/support/users/mrgrooves/)
 * (@mrgrooves)
 * [2 years, 5 months ago](https://wordpress.org/support/topic/apache-error-preg_match-compilation-failed/#post-17300875)
 * There is a need, I am afraid. The cart rebuilding was not working without it 
   and it took us ages to figure out the issue. Once I added the exclusion rule,
   the function worked.
 *  Plugin Author [Emre Vona](https://wordpress.org/support/users/emrevona/)
 * (@emrevona)
 * [2 years, 5 months ago](https://wordpress.org/support/topic/apache-error-preg_match-compilation-failed/#post-17300880)
 * do not worry about it. please remove the rule and tell me the url which you want
   to exclude it. I will check it that it is excluded or not.
 *  Thread Starter [mrgrooves](https://wordpress.org/support/users/mrgrooves/)
 * (@mrgrooves)
 * [2 years, 5 months ago](https://wordpress.org/support/topic/apache-error-preg_match-compilation-failed/#post-17300885)
 * I can’t exclude it, as we have already confirmed this with 100% certainty to 
   be the issue. Without that specific rule, all abandoned cart urls were defaulting
   to the homepage. Unless you implemented some changes to the plugin since July
   11, 2023 that would automatically exclude all URLs with string queries, there
   is no reason why it would now work.
 * Did you implement any such change?
 *  Plugin Author [Emre Vona](https://wordpress.org/support/users/emrevona/)
 * (@emrevona)
 * [2 years, 5 months ago](https://wordpress.org/support/topic/apache-error-preg_match-compilation-failed/#post-17300889)
 * But your regex rule didn’t used to work, so you had lots of warnings in the log
   file.
 * you can add the following rule.
 * ![](https://i0.wp.com/i.ibb.co/qR6R1LC/Screen-Shot-2023-12-26-at-00-23-07.png?
   ssl=1)
 *  Thread Starter [mrgrooves](https://wordpress.org/support/users/mrgrooves/)
 * (@mrgrooves)
 * [2 years, 5 months ago](https://wordpress.org/support/topic/apache-error-preg_match-compilation-failed/#post-17300891)
 * Well, it worked, but with errors. The carts were getting recovered. I added an
   exclude condition now similar to your suggestion (no regex) and the cart recovery
   works.
 * Thank you very much for pointing me in the right direction with regards to the
   regex warning.
 *  Plugin Author [Emre Vona](https://wordpress.org/support/users/emrevona/)
 * (@emrevona)
 * [2 years, 5 months ago](https://wordpress.org/support/topic/apache-error-preg_match-compilation-failed/#post-17300892)
 * You’re welcome 🙂 If you vote, it would make me so happy.
 * [https://wordpress.org/support/plugin/wp-fastest-cache/reviews/](https://wordpress.org/support/plugin/wp-fastest-cache/reviews/)
 *  Thread Starter [mrgrooves](https://wordpress.org/support/users/mrgrooves/)
 * (@mrgrooves)
 * [2 years, 5 months ago](https://wordpress.org/support/topic/apache-error-preg_match-compilation-failed/#post-17300893)
 * You bet I will! 👍

Viewing 15 replies - 1 through 15 (of 17 total)

1 [2](https://wordpress.org/support/topic/apache-error-preg_match-compilation-failed/page/2/?output_format=md)
[→](https://wordpress.org/support/topic/apache-error-preg_match-compilation-failed/page/2/?output_format=md)

The topic ‘Apache error: preg_match(): Compilation failed’ is closed to new replies.

 * ![](https://ps.w.org/wp-fastest-cache/assets/icon-256x256.png?rev=2064586)
 * [WP Fastest Cache - WordPress Cache Plugin](https://wordpress.org/plugins/wp-fastest-cache/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/wp-fastest-cache/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/wp-fastest-cache/)
 * [Active Topics](https://wordpress.org/support/plugin/wp-fastest-cache/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/wp-fastest-cache/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/wp-fastest-cache/reviews/)

 * 17 replies
 * 2 participants
 * Last reply from: [mrgrooves](https://wordpress.org/support/users/mrgrooves/)
 * Last activity: [2 years, 5 months ago](https://wordpress.org/support/topic/apache-error-preg_match-compilation-failed/page/2/#post-17300896)
 * Status: resolved