Regex Rewrite AND pattern

I would like to create a regex for rewriting.

Rewrite the whole request to index.php (no match needed) that doesn't start with / api or end ('.html' or '.js' or '.css' or '.png')

My example is still there, but doesn't work well:

(!^/api|!\\.html$|!\\.js$|!\\.css$|!\\.png$) /index.html [L]

      

Example:

/a/b/c.css -> not rewrite
/a/b/c -> rewrite
/api/something -> not rewrite

      

+3


source to share


1 answer


You should simply do this:

RewriteRule !(^/api.*|.*\.(html|png|js|css)$) /index.php [L]

      



See information on using operator NOT

( !

) here

+1


source







All Articles