Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

RewriteRule cannot compile regular expression

My previous server working fine.. Today I changed new server and getting RewriteRule cannot compile regular expression on my htaccess.

How to fix this line.

RewriteRule ^category/([0-9]+)(?:/([^/]+)(?:/([^/]+))?)(?:/([^/]+)(?:/([^/]+))?)?/$ ./category.php?pid=$1&catname=$2&page=$3 [L]

Let me know :)

like image 385
wow Avatar asked Dec 01 '25 19:12

wow


1 Answers

You are probably using a different Apache version with a different regular expression engine. The Apache versions since 1.3 use POSIX ERE while the versions since 2.0 use PCRE. And only PCRE support the non-capturing group (?:expr).

So try a pattern without them:

RewriteRule ^category/([0-9]+)(/([^/]+)(/([^/]+))?)(/([^/]+)(/([^/]+))?)?/$ ./category.php?pid=$1&catname=$3&page=$5 [L]
like image 195
Gumbo Avatar answered Dec 04 '25 08:12

Gumbo



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!