Reputation: 10167
How can I redirect all requests going to web root to another folder (e.g. public/)?
I've already tried this (contents of .htaccess in web root):
RewriteEngine on
RewriteRule ^(.*)$ public/$1
But now I have duplicate content for addresses: address.tld/ and address.tld/public/
I would like to redirect address.tld/public/ to address.tld/, so there won't be any duplicates, but I just don't know how to do it and not get into redirecting cycle...
Upvotes: 2
Views: 724
Reputation: 655129
Try these rules:
RewriteCond %{THE_REQUEST} ^GET\ /public/
RewriteRule ^public/(.*) /$1 [L,R=301]
RewriteRule !^public/ public%{REQUEST_URI} [L]
Upvotes: 2