Apache URL重写

假设我在www.domain.com/products/上有内容

在产品文件夹中,我有几个HTML文件都以“big-”开头。 例如:

big-product01.html big-product02.html 

如何重写我的URL,以便可以通过键入以下内容来访问这些URL:

 www.domain.com/products/big/product01 www.domain.com/products/big/product02 ... 

在此先感谢您的任何帮助!

使用mod_rewrite (不应该改变浏览器中的URL):

 <Directory /var/www> RewriteEngine on RewriteRule ^products/big/(product[0-9][0-9]*)$ /products/big-$1.html [L] </Directory> 

如果<Directory>块有一个相对path,你也需要一个RewriteBase指令。

使用mod_alias (将更改浏览器中的URL):

 RedirectMatch permanent /products/big/(product[0-9][0-9]*)$ /products/big-$1.html