How to redirect site to another folder at the public_html level using htaccess

-1

I have a site created and the files are in the public_html folder. We created a new one in the 2018 folder that is at the same hierarchical level as public_html

How can I do when to access the domain.com, it accesses the folder 2018 and not the public_html?

    
asked by anonymous 18.12.2018 / 10:58

1 answer

1

Fortunately , for security, you can not redirect through .htaccess to a top-level directory than your document root . Consequently, a directory on the same level can not be accessed.

There are, of course, alternatives to solving your problem. I quote two:

First

You can put the 2018 directory within the public_html directory. With a .htaccess setting (see below), you can make the site point to the contents of this 2018 sub-directory. See:

RewriteEngine on
RewriteCond %{HTTP_HOST} ^exemplo\.com\.br$ [NC,OR]
RewriteCond %{HTTP_HOST} ^www\.exemplo\.com\.br$
RewriteCond %{REQUEST_URI} !nome_diretorio/
RewriteRule (.*) /nome_diretorio/$1 [L]

Just swap exemplo\.com\.br for the desired domain. Also change nome_diretorio to the rephased site directory - in this case, 2018 .

Second

You can ask the host controller to allow one more directory for your site. This is unlikely and impractical for both.

    
18.12.2018 / 11:51