mod_rewrite除一个文件夹之外的所有文件请求

时间:2013-01-17 12:48:18

标签: .htaccess mod-rewrite

有许多类似的问题,但所提供的解决方案都不符合我的需要。

我想将文件夹上的所有请求转发到某个网址,但应将一个请求转发到另一个网址。 这是我到目前为止所得到的:

RewriteCond %{REQUEST_URI} !^/test/test.html$<br />
RewriteRule .? http://www.example.com [L,NC,QSA]

现在缺少的是请求/test/test.html应转发给 www.example.com/test/index.html

我正在尝试保护该文件夹上的任何请求(测试),除非有人知道某个网址(test / test.html),然后应将其转发到test / index.html

任何帮助将不胜感激!

1 个答案:

答案 0 :(得分:0)

我认为这就是你要找的东西

# internally redirect /test/test.html to /test/index.html
RewriteRule ^test/test\.html$ /test/index.html [L]
# don't do any more rewrites on the url: /test/index.html
RewriteRule ^test/index\.html$ - [L]
# internally redirect all (other) request to the root
RewriteRule .* / [L]
相关问题