Alex
Alex

Reputation: 10226

Why does this redirect apply?

I have a simple Redirect in my htaccess file:

Redirect 301 /foobar /johndoe/foobar

unfortunately, this url:

/foobar/barfoo also gets redirected - why? In my understanding, only /foobar should be redirected when using the Redirect command, shouldnt it?

I feel that this is more comfy than writing RewriteRules

Upvotes: 2

Views: 37

Answers (1)

Alex
Alex

Reputation: 10226

As it turns out, Redirect seems to just check if the URL to check is in the beginning of the current path (at least my tests say that, the documentation is not 100% clear about it).

But, to avoid using RewriteRule (since it might be overkill), simple RedirectMatch also works:

RedirectMatch 301 "^/foobar$" "/johndoe/foobar"

I would still be thankful for additional advice, whether this isnt possible to solve without "regex" and/or RewriteRule

Upvotes: 1

Related Questions