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

Asked

Viewed 1,359 times

-1

I have a website 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 access domain.com.br, it accesses folder 2018 and not public_html?

1 answer

1


Fortunately, by security, you may not redirect through .htaccess to a level directory higher than your Document root. Consequently, a directory on the same level cannot be accessed.

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


First

You can put the directory 2018 inside the directory public_html. With a configuration of .htaccess (see below), you can make the site point to the content of this sub-directory 2018. Behold:

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 exchange exemplo\.com\.br for the desired domain. Also exchange nome_diretorio directory of the website - in this case, 2018.

According to

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

  • 1

    I get it, I’m playing inside the public so, thanks!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.