0

I'm trying to achieve the following with .htaccess:

  • domain.tld/ displays the content originally at domain.tld/home/
  • if you visit domain.tld/home/, you are redirected to domain.tld/ (to avoid duplicate content)

I tried the following, but it resulted in an infinite loop:

RewriteEngine on
RewriteRule ^$ /home/ [L]
RedirectMatch 301 ^/home/$ /

Any ideas? Thank you.

Gabriel Bianconi
  • 1,179
  • 3
  • 19
  • 37

1 Answers1

0

Found the solution:

RewriteEngine on
RewriteCond %{THE_REQUEST} \ /+home/([^\?\ ]*)
RewriteRule ^ /%1 [R=301,L]
RewriteRule ^$ /home/ [L]

Based on: How to avoid duplicate content mapping urls with htaccess

Community
  • 1
  • 1
Gabriel Bianconi
  • 1,179
  • 3
  • 19
  • 37