0

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 :-/

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.