请教一个 Apache 的 RewriteRule 问题

2015-12-19 13:33:22 +08:00
 plqws
```
RewriteEngine On
RewriteCond %{REQUEST_URI} !^/cache/
RewriteRule ^(.*)$ /cache/$1
#我想要如果匹配到 /cache/$1 的话就此结束
#若没有匹配到 /cache/$1 的话就执行下面的那个 index.php
RewriteRule ^ index.php [QSA,L]
```

目录结构
/root
-cache
|-test.txt
-index.php
-.htaccess

比如访问 /test.txt ,就能直接访问到 /cache/test.txt ,若访问 /hello.txt 就重写成 /index.php?blahblahblah

该如何实现呢?
1597 次点击
所在节点    Apache
1 条回复
Slienc7
2015-12-19 14:07:38 +08:00
[L]

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/244652

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX