apache - 将所有流量转发到一个子文件夹,将一个子文件夹转发到另一个子文件夹
问题描述
这是我服务器上文件夹逻辑的简化版本。
├── rest/
│ └── api/
│ ├── account
│ ├── posts
│ └── settings
├── src/
│ ├── index.html
| ├── scripts.js
│ └── about/
| └── index.html
└── public/
├── index.html
├── scripts.js
└── about/
└── index.html
服务器设置:Ubuntu 16.04 Apache 2
我想要实现的是:
- 访问
/
将显示来自/public/index.html
- 访问
/about
将显示来自/public/about/index.html
- 访问
/api/account
将显示来自/rest/api/account
这是我当前的.htaccess
设置
RewriteEngine On
RewriteBase /
RewriteRule ^(.*)$ /public/$1 [L,NC]
这适用于重定向/
到/public/index.html
但不适用于api
.
解决方案
你不能这样做:
RewriteEngine On
RewriteBase /
RewriteRule ^(api/.*)$ /rest/$1 [L,NC]
RewriteRule ^(.*)$ /public/$1 [L,NC]
推荐阅读
- php - Apache 无法识别隐藏的 .index.php 文件
- mysql - 如何在一个查询中计算多个结果的最大值和最小值?
- python - Kivy - 运动事件:on_mouse_pos
- tensorflow - Tensorflow:“您必须使用 dtype float 和 shape [?,2] 为占位符张量 'y' 提供一个值”
- javascript - webpack4 css捆绑不适用于自定义样式名称
- python - “page”/create 发生冲突,因为 slug django
- scala - 上下文感知类型类
- apache-kafka - Kafka Offsets.storage
- anylogic - 返工产品所花费的时间 - Anylogic
- r - 如何检测以'abc'开头然后有'n'个数字然后再有字母的字符串?