| Directive | Syntax |
|---|
RewriteEngine | RewriteEngine On|Off |
RewriteBase | RewriteBase /path/ |
RewriteCond | RewriteCond TestString Pattern [flags] |
RewriteRule | RewriteRule Pattern Substitution [flags] |
RewriteOptions | RewriteOptions inherit|IgnoreInherit |
RewriteMap | RewriteMap name txt|rnd|int:/path |
%{REQUEST_URI}, %{REQUEST_FILENAME}, %{QUERY_STRING}, %{HTTP_HOST}, %{HTTPS}, %{REMOTE_ADDR}, %{REQUEST_METHOD}, %{HTTP_USER_AGENT}, %{HTTP_REFERER}
| Flag | Description |
|---|
[NC] | Case-insensitive match |
[OR] | Combine with next condition using OR (default is AND) |
| Flag | Description |
|---|
[L] | Last rule — stop processing |
[R=301] | External redirect with status code |
[QSA] | Append query string |
[F] | Forbidden (403) |
[G] | Gone (410) |
[NE] | No escape — don’t encode special characters |
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1 [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/$ /$1 [R=301,L]