将包含生成的ID的新mod_rewrite规则添加到现有配置

时间:2011-07-18 09:31:25

标签: .htaccess mod-rewrite

我想的另一个......

如何重写

http://domain.com/images/download/30

其中30是生成的ID

http://domain.com/pages/files/download.php?id=30

我目前的尝试是这样的:

RewriteRule .+images/download/(\d+) /pages/files/download.php?id=$1

我在哪里错了?

我的.htaccess的其余部分是:

# turn rewriting on
RewriteEngine on

Options +FollowSymLinks

RewriteRule ^([^/\.]+)/?$ /index.php?page=$1 [L,NC,QSA]
RewriteRule ^([^/\.]+)/([^/\.]+)/?$ /index.php?page=$1&var1=$2 [L,NC,QSA]
RewriteRule ^([^/\.]+)/([^/\.]+)/([^/\.]+)/?$ /index.php?page=$1&var1=$2&var2=$3 [L,NC,QSA]
RewriteRule ^([^/\.]+)/([^/\.]+)/([^/\.]+)/([^/\.]+)/?$ /index.php?page=$1&var1=$2&var2=$3&var3=$4 [L,NC,QSA]

1 个答案:

答案 0 :(得分:3)

在其他规则添加之前

RewriteRule ^images/download/(\d+)$ /pages/files/download.php?id=$1 [L]

并且在/pages/文件夹中你应该关闭重写引擎以避免对其他规则进行重新编写