Reputation: 678
So, I need something pretty simple, and yet I can seem to get it right anyhow. I need to redirect
http://mydomain.com/help/4/something/else/
to
http://mydomain.com/help/index.php/4/something/else
And this should work only if there is a "/help/" in the URL.
I've been trying it whole day, the last I came up to was
RewriteCond %{REQUEST_URI} ^/(help)/
RewriteRule . help/index.php [L]
but it's not working :-/
Upvotes: 0
Views: 89
Reputation: 7084
The problem here is that you are rewriting the URI, but not adding on the additional parts, so whenever your rule matches, it will rewrite it as /help/index.php
.
The following rule, without a RewriteCond
should do the job:
RewriteRule ^help/(.*)$ help/index.php/$1
It works by only ever rewriting a URI that has help/
as the first part of the path, then it changes that to help/index.php/$1
- the $1
part is comes in the braces in the matching rule.
Using your own example, http://example.com/help/4/something/else/ becomes http://example.com/help/index.php/4/something/else/.
Note that I took off the [L]
flag, as that would stop any further rules from happening, which due to what you're rewriting to, you may not want.
Upvotes: 1