I'm not too used to work with htaccess files so I struggled for a while on this one :
I'd like to know how can I rewrite an URL (example.com/foo/bar) to (example.com/index.php?q=/foo/bar) AFTER adding a trailing slash (301 redirect) to the initial URL :
I know how to add the trailing slash alone :
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !(.*)/$
RewriteRule ^(.*)$ http://exemple.com/$1/ [L,R=301]
And how to rewrite to index.php :
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?q=$1 [L]
But I just can't figure how to do both at the same time...
Any help is more than welcome !
Pierre Fraisse
RewriteEngine on
part. I would however use^(.+)$
– Gerben