0

我正在尝试将请求转发到一个文件夹,如下所示:

RewriteRule ^(contact)/(.+)$ $2

它工作正常,但更改contact[a-z]+不会按预期运行:

RewriteRule ^([a-z]+)/(.+)$ $2

这是使用第一种方法而不使用第二种方法的示例 URL:

http://localhost/bb/contact/company/img/group/3.png
Root is : http://localhost/bb/
4

1 回答 1

0

If Root is : http://localhost/bb/ then you will need RewriteBase as well:

RewriteEngine On
RewriteBase /bb/

RewriteRule ^([a-z]+)/(.+)$ $2 [L,NC]

This will internally forward http://localhost/bb/contact/company/img/group/3.png to http://localhost/bb/company/img/group/3.png

Reference: Apache mod_rewrite Introduction

于 2013-10-06T07:55:04.777 回答