skip to Main Content

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?

2

Answers


  1. 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]
    
    Login or Signup to reply.
  2. 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.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search