Options -Indexes
Options -MultiViews

RewriteEngine On

# Protect sensitive directories
RewriteRule ^include/ - [F,L]
RewriteRule ^pages/ - [F,L]

# Skip real files and directories
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

# URL rewriting rules
# users/register -> index.php?p=register
RewriteRule ^users/register/?$ index.php?p=register [QSA,L]

# users/login -> index.php?p=login
RewriteRule ^users/login/?$ index.php?p=login [QSA,L]

# users/logout -> index.php?p=logout
RewriteRule ^users/logout/?$ index.php?p=logout [QSA,L]

# users/lost -> index.php?p=lost
RewriteRule ^users/lost/?$ index.php?p=lost [QSA,L]

# user/password -> index.php?p=password
RewriteRule ^user/password/?$ index.php?p=password [QSA,L]

# user/email -> index.php?p=email
RewriteRule ^user/email/?$ index.php?p=email [QSA,L]

# user/donate -> index.php?p=donate
RewriteRule ^user/donate/?$ index.php?p=donate [QSA,L]

# user/administration -> index.php?p=administration
RewriteRule ^user/administration/?$ index.php?p=administration [QSA,L]

# download -> index.php?p=download
RewriteRule ^download/?$ index.php?p=download [QSA,L]

# ranking/players -> index.php?p=players
RewriteRule ^ranking/players/?$ index.php?p=players [QSA,L]

# ranking/guilds -> index.php?p=guilds
RewriteRule ^ranking/guilds/?$ index.php?p=guilds [QSA,L]

# news -> index.php?p=news
RewriteRule ^news/?$ index.php?p=news [QSA,L]

# news/read/ID -> index.php?p=read&id=ID
RewriteRule ^news/read/([0-9]+)/?$ index.php?p=read&id=$1 [QSA,L]

# admin -> index.php?p=admin
RewriteRule ^admin/?$ index.php?p=admin [QSA,L]

# vote4coins -> index.php?p=vote4coins
RewriteRule ^vote4coins/?$ index.php?p=vote4coins [QSA,L]

# referrals -> index.php?p=referrals
RewriteRule ^referrals/?$ index.php?p=referrals [QSA,L]

# redeem -> index.php?p=redeem
RewriteRule ^redeem/?$ index.php?p=redeem [QSA,L]

# characters -> index.php?p=characters
RewriteRule ^characters/?$ index.php?p=characters [QSA,L]

# Fallback - everything else to index.php
RewriteRule ^(.*)$ index.php [QSA,L]
