Forum Moderators: phranque
Sorry for the vague title but i couldn't thing of anything more specific. I've done was too much googling and haven't found a solution.
here's what i have so far:
RewriteCond %{REQUEST_URI}!^/images/
RewriteRule ^(.*)/$ /?p=$1 [L]
and this works as i hoped for
eg type in domain.com/page/ goes to domain.com/?p=page
but if someone types in domain.com/page they get a page not found error. If it was a real subfolder they'd get redirected to domain.com/page/. I'd prefer to redirect the users to domain.com/page/ rather than rewriting the url (domain.com/page) to domain.com/?p=page
Does anyone have a solution to my problem
Thanks
Welcome to WebmasterWorld!
You can add code to explicitly test for a trailing slash on any path that does not contain a filetype -- as indicated by the presence of a "." in the URL-path:
# If path does not end in "/"
RewriteCond $1!/$
# and does not contain a "."
RewriteCond $1!\.
# then add trailing slash and redirect
RewriteRule (.*) http://www.example.com/$1/ [R=301,L]
I got it to work after a bit of tweeking, for some reason the code you provided didn't work.
This is the code i used:
# If path does not end in "/"
RewriteCond %{REQUEST_URI}!/$
# and does not contain a "."
RewriteCond %{REQUEST_URI}!\.
# then add trailing slash and redirect
RewriteRule ^(.*) /$1/ [R=301,L]
Is this ok, or is it flawed somewhere?
BTW nice site here, large active community, don't know how i missed it for so long.