G
G
glem13372020-06-05 11:16:24
htaccess
glem1337, 2020-06-05 11:16:24

How to make a redirect only for the second level of nesting?

I can’t understand how you can get such a redirect so that when you go to https://site.com/first/second/ there is a redirect to https://site.com/first/target/, but at the same time what would happen when you go to https://site.com/first/second/ there was no redirect to https://site.com/first/second/third/ .

I thought something like this would work, but it didn't.

RewriteRule ^/first/second/$ https://site.com/first/target/ [R=301,L]

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
dodo512, 2020-06-05
@glem1337

RewriteRule ^/

This will work if you put the rule directly in <VirtualHost>.
And in .htaccess, the input RewriteRule receives a line already without /.
RewriteRule ^first/second/$ https://site.com/first/target/ [R=301,L]

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question