关于apache2的RewriteRule

I have a problem with the Rewrite rules. I'd like to redirect domain.xx/example to domain.xx/index.php?content=example

This would actually work, but I also have a file named example.php in the same folder (domain.xx/example.php). Whenever I open domain.xx/example, the server opens example.php instead of redirecting me to index.php?content=example.

The mod-rewrite is on and works fine when I delete the example.php file.

RewriteEngine On
RewriteBase /
RewriteRule ^example$ index.php?content=example [NC,L]

That is because of MultiViews option.

Add this line on top of your .htaccess:

Options -MultiViews

add this to your htaccess file:

# if a directory or a file exists, use it directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

so the example.php will be served directly, then add your rule.

Rewrite rules are regular expressions, so you just need to remove the ending character to match both example and example.php

RewriteRule ^example index.php?content=example [NC,L]