Luca
Luca

Reputation: 76

htaccess to hide some folders and seo

I have a site with the following folder structure

/folder1
/folder2/folder3
/othfolder1
/othfolder2

I would like to obtain this

mysite.com -> will show content of /folder1 (without showing the folder on URI, ok for subfolders)
mysite.com/folder3 -> will show content of /folder2/folder3 (without showing folder2 on URI)
mysite.com/othfolderX -> will just remain as it is (/othfolder1 or /othfolder2 or so on), no rewrite

Is this possibile with htaccess rewrite? Will this be any problem with current seo and search results for the site?

Upvotes: 1

Views: 54

Answers (2)

anubhava
anubhava

Reputation: 785196

You may try these rules in your site root .htaccess:

RewriteEngine On

RewriteRule ^$ folder1/ [L]

RewriteRule ^(folder3)/?$ folder2/$1/ [L,NC]

Make sure you test it after completely clearing your browser cache.

Upvotes: 0

RavinderSingh13
RavinderSingh13

Reputation: 133528

Could you please try following, written as per your shown samples only.

RewriteEngine ON
RewriteCond %{REQUEST_URI} ^/?$
RewriteRule ^.*$ folder1 [L]

RewriteCond %{REQUEST_URI} ^/(folder3)/?$ [NC]
RewriteRule ^(.*) folder2/%1 [L]

Upvotes: 1

Related Questions