Damian Doman
Damian Doman

Reputation: 532

WordPress warning: preg_match(): Compilation failed: nothing to repeat at offset 1

Suddenly my friend's WordPress based website started showing up this warning on subpages:

Warning: preg_match(): Compilation failed: nothing to repeat at offset 1 in /wp-includes/class-wp.php on line 218

Lines 218/219 that are returned in the warning are as follows:

if ( preg_match("#^$match#", $request_match, $matches) ||
     preg_match("#^$match#", urldecode($request_match), $matches) ) {

Seems like the code is responsible for URL reworking.

Any ideas what could possibly be going wrong?

Upvotes: 2

Views: 6750

Answers (2)

Fuller93
Fuller93

Reputation: 159

I had this very same issue and it was driving me crazy!

It was a simple fix for me, hopefully will be for anyone else who has the same issue!

All I had to do was login to the backend of the site with /wp-admin and then go to Settings > Permalinks and then set it to 'Post Name' and then click 'Save Changes'. Hard refresh the page/s you had the issue on and it might just be resolved.

Upvotes: 0

wp78de
wp78de

Reputation: 18980

The error does not appear on the homepage but on sub-pages. Thus, I guess the permalinks structure is corrupt. An often suggested fix goes like this:

  1. temporary disable all your plugins! Do not skip this step.
  2. go to the WordPress admin dashboard: Settings -> Permalinks note what you have in the custom permalinks field somewhere else
  3. temporary switch to default permalinks. Save settings.
  4. check the page in question: are the preg_match errors gone?
  5. switch back to your previous custom permalinks setting
  6. re-enable back all the plugins, the pages should be back to normal.

Upvotes: 5

Related Questions