简体   繁体   English

如何使用htacces重定向到另一个Directoy

[英]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. 我的项目( myproject.uz )包含许多位于根文件夹中的文件夹。 For example, let's say that there are 4 folders api, backend, active, and terminal that are places in the root. 例如,假设根目录中有4个文件夹api, backend, active, and terminal 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. 传统上,为了打开其中一个文件夹,我将必须在浏览器中键入www.myproject.uz/api ,以便我可以访问该特定文件夹。 Is there a way to link one specific folder that would open up automatically once I type in www.myproject.uz . 有没有一种方法可以链接一个特定的文件夹,当我输入www.myproject.uz ,该文件夹将自动打开。 For example, every time a user enters www.myproject.uz , folder c opens up automatically. 例如,每次用户输入www.myproject.uz ,文件夹c都会自动打开。 At the same time I need that a user to see only **www.myproject.uz** instead of www.myproject.uz/terminal . 同时,我需要用户仅看到**www.myproject.uz**而不是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 adminboy@gmail.com
    ServerName localhost
    DocumentRoot "f:/Apache/home/myproject/www"
    ServerAlias  "myproject.uz" "www.myproject.uz" 
</VirtualHost>

You can use this code in your DOCUMENT_ROOT/.htaccess file: 您可以在DOCUMENT_ROOT/.htaccess文件中使用以下代码:

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. 这将打开/terminal/以在浏览器中输入http://www.domain.com

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM