lucy24 - 10:57 pm on Apr 15, 2012 (gmt 0)
I wasn't aware that browsers reacted differently to urls and I assume that what is shown in Firefox's address bar is the result of its own 'cosmetic' rewriting or something. As I am interested in how the search engines see my urls I need to remove the trailing slash as well for consistancy.
Oh, now that's interesting. One part of what you noticed is done by all browsers, except possibly some very very old one. If you type in (or bookmark)
the browser itself will add a trailing slash before the request ever reaches your server. So you can get rid of "index.php" but not the preceding slash unless you want to risk an infinite redirect. (The kind that your browser intercepts, not the Apache kind.)
Since the "index.php" only gets removed in some browsers, you don't have to worry that the config file itself contains this rewrite. That could get messy.
Your rules are still in the wrong order, but we'll get there. And you really do need to use example.com. You probably did some jiggery-pokery to keep your examples from turning into clickable links-- but if you use example.com you won't have to, because the Forums are coded to exempt (www.)example.(any reasonable extension). And when people cut&paste they don't have to do the same jiggery-pokery all over again.
Now, here you've got the dreaded Leading .+ which is almost as bad as a leading .*
RewriteRule ^(.+[^/])/$ http://www.example.com/$1
The form you need is ^(([^/.]+/)*[^/.]+)/$
where the change from [^/] to [^/.] is not functionally necessary but will shave a few nanoseconds off server time because it can then stop as soon as it meets an extension.
But don't change it yet. Directories have a final slash; pages don't.
/directory/otherdirectory/ = /directory/otherdirectory/index.php
/directory/pagename = /directory/pagename.php
(Simplifying for the sake of example.)
The final slash gets added if you want the requested URL to look like a directory. (If it really is a directory you need not do anything, because that is mod_dir's job.) Conversely, it only gets deleted if you want the requested URL to look like a page. If a human comes along and types in
you don't want to redirect them to
because there's no such place. So you'll need some more Conditions.