2

Small question,

I want my website www.example.nl/nl redirect to www.example.nl/nl/home

But If I do this:

Redirect 301 /nl/ https://www.example.nl/nl/home

Then I get an infinite loop, because the home url contains the nl variable

What is the best way to fix this :)?

MrWhite
  • 43,179
  • 8
  • 60
  • 84

1 Answers1

2

Since Redirect is prefix matching, this will indeed result in a redirect loop. You need to use the RedirectMatch directive instead, which uses regex instead of simple prefix matching. For example:

RedirectMatch 301 ^/nl/$ https://www.example.nl/nl/home

This now matches a request for /nl/ only and not /nl/<anything>.

MrWhite
  • 43,179
  • 8
  • 60
  • 84