Page is a not externally linkable
lucy24 - 7:21 am on Dec 10, 2012 (gmt 0)
# redirect requests containing index.php/ to their NON index.php/ version
rewritecond %{THE_REQUEST} ^[A-Z]+\ /index\.php(/[^\ ]*)?\ HTTP/
rewriterule ^index\.php(/(.*))?$ http://www.example.com$1 [R=301,L]
This will only work on requests in the form
www.example.com/index.php{possibly-more-garbage-here}
not for anything like
www.example.com/directory/index.php{et cetera}.
Is that all you need?
(/(.*))?
Since you're not capturing the post-slash bit separately, you don't need parentheses: a plain
(/.*)?
will do.
(/[^\ ]*)?
The character you're groping for is \S as in
(/\S*)?
Remember that in RegEx, if \a means something, \A almost always means [^\a]. \S technically means "no whitespace of any kind" but in this context it doesn't matter, because you're in strict single-line mode, and other space-type things like tabs or non-breaking spaces don't occur.
In fact all you need in the REQUEST line is
\S*
because the Rule itself has already specified that if anything comes after "index.php" it has to start with a slash.
example.com/index.php/some-old-url still redirects twice
What's the intervening step? Live Headers, or whatever you're using, will say.