P
P
photosho2021-10-06 18:06:28
htaccess
photosho, 2021-10-06 18:06:28

Why is the redirect rule executed when the address does not exactly match?

There is a rule in htaccess:

Redirect 301 /cat-1/cat-2 http://site.ru/newcat/

When processing the following address:

http://site.ru/cat-1/cat-2/cat-3/material/

This rule fires and redirects to the page:

http://site.ru/newcat//cat-3/material/

It seems that it replaces the "/cat-1/cat-2" part and then just adds the rest of the address. Unless, in my case this rule should be executed?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
dodo512, 2021-10-06
@dodo512

Redirect is exactly how it works, it just checks if the path prefix matches.
To find an exact match, there is RedirectMatch.

RedirectMatch 301 ^/cat-1/cat-2$ http://site.ru/newcat/

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question