RewriteEngine On #check if file or directory real exists: RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d #do the rule only if the address has no extension: RewriteCond %{REQUEST_URI} !\.[[:alnum:]]+$ #replace /whatever to /whatever/, not apply to whatever/! RewriteRule ^(.+[^/])$ /$1/ [R=301] #do the rule only if the address ends with trailing slash: RewriteCond %{REQUEST_URI} ^.*/$ #if the rule ends with trailing slash then redirect to index.php.. RewriteRule ^(.*)/$ /index.php?p=$1 [L]