M
M
Maxim2021-12-09 01:49:51
htaccess
Maxim, 2021-12-09 01:49:51

How to redirect all pages of different nesting to one, but leave the top one without redirection?

I need to do a .htaccess 301 redirect to get the following results.
All subsequent pages must link to: example.com/v5dl/, but do not affect the topmost example.com/feed/

Pages intended for redirection have different levels of nesting and, accordingly, in different directories
Examples:

example.com/a/feed/
example.com/x/u/feed/
example.com/x/y/feed/
example.com/r/s/p/feed/
example.com/c/v/n/t/d/feed/

and so on

When I use:
RewriteEngine On
RewriteCond %{REQUEST_URI} /feed/$
RewriteRule ^.*$ https://example.com/v5dl/? [R=301,L]

Everything is going fine, but example.com/feed/the (upper) one also gets redirected.

Thank you for your help!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
dodo512, 2021-12-09
@krok-m

Just add a dot to the template./feed/$

RewriteCond %{REQUEST_URI} ./feed/$
RewriteRule ^.*$ https://example.com/v5dl/? [R=301,L]

Or move the template to the RewriteRule.
RewriteRule /feed/$ https://example.com/v5dl/? [R=301,L]

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question