Skip to content

Rewrite

DirectiveSyntax
RewriteEngineRewriteEngine On|Off
RewriteBaseRewriteBase /path/
RewriteCondRewriteCond TestString Pattern [flags]
RewriteRuleRewriteRule Pattern Substitution [flags]
RewriteOptionsRewriteOptions inherit|IgnoreInherit
RewriteMapRewriteMap name txt|rnd|int:/path

%{REQUEST_URI}, %{REQUEST_FILENAME}, %{QUERY_STRING}, %{HTTP_HOST}, %{HTTPS}, %{REMOTE_ADDR}, %{REQUEST_METHOD}, %{HTTP_USER_AGENT}, %{HTTP_REFERER}

FlagDescription
[NC]Case-insensitive match
[OR]Combine with next condition using OR (default is AND)
FlagDescription
[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
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1 [R=301,L]
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/$ /$1 [R=301,L]