Redirect with htaccess keeping the URL

Asked

Viewed 2,206 times

5

I need to redirect a registered domain (domain.com.br) to a domain folder of my hosting (domain.com/exclusive), but I want to keep the domain.com.br in the address bar, without losing the integrity of the URL, that is, all pages also stay in the address bar ex: dominio.com.br/contact, /service, /institutional....

Is it possible to make this rule in htacess? Can someone help me?

  • could not solve this in virtualhost?

2 answers

3

Write your .htaccess thus

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^$ exclusive/index.php [L]
    RewriteRule ^(.*)$ exclusive/$1 [QSA,L]
</IfModule>

If you want to implement friendly URL:

Implementing Router-Friendly URL

  • Dude, I’ve been trying to figure this out for three days. Thanks!

  • 1

    Oops! Good! Orders

  • Can I ask you a question? Is this a redirect or an inclusion? Type.. does it include the directory or redirect the user to the directory? Just out of curiosity..

  • 1

    When accessing, instead of using the primary folder, the call goes to another folder. It is a type of redirect, but without returning it to the client. It’s an internal action only. For example, using the above example, a domain-only URL will call the "unique/index.php" by overriding the index of the root folder. Any other URL will use the "exclusive" folder as the root folder.

  • Got it. Thanks again.

-3

It is possible to do so. htaccess yes, but I recommend an easier and more efficient way using the property of Javascript(window.location.href) making you can customize putting time and etc... to your liking.

Example of the property window.location.href
window.location.href = 'http://www.google.com/'; // Redireciona você para o site da Google

  • Actually window.Location only redirects to a certain address, it would not solve my problem.

Browser other questions tagged

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