Sardor Dushamov
Sardor Dushamov

Reputation: 1667

How to redirect to another directoy with htacces

So here is the situation. My project (myproject.uz) contains many folders that are located in the root folder. For example, let’s say that there are 4 folders api, backend, active, and terminal that are places in the root. Traditionally, in order to open one of the folders, I will have to type www.myproject.uz/api in the browser so that I can access that specific folder. Is there a way to link one specific folder that would open up automatically once I type in www.myproject.uz. For example, every time a user enters www.myproject.uz, folder c opens up automatically. At the same time I need that a user to see only **www.myproject.uz** instead of www.myproject.uz/terminal. The “invisibility” property must be applied only to one single folder.

How do I do that?

www/
    backend/
    active/
    api/
    terminal/
    index.php
    ...

My vhosts configuration :

<VirtualHost *:80>
    ServerAdmin [email protected]
    ServerName localhost
    DocumentRoot "f:/Apache/home/myproject/www"
    ServerAlias  "myproject.uz" "www.myproject.uz" 
</VirtualHost>

Upvotes: 0

Views: 31

Answers (1)

anubhava
anubhava

Reputation: 785058

You can use this code in your DOCUMENT_ROOT/.htaccess file:

RewriteEngine On
RewriteBase /

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^((?!terminal/).*) terminal/$1 [L,NC]

This will open /terminal/ for entering http://www.domain.com in browser.

Upvotes: 3

Related Questions