All pastes #382242 Raw Edit

Miscellany

public text v1 · immutable
·published 2007-03-05 13:10 UTC
rendered paste body
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]