mod_rewrite:RewriteRule将某些URL重定向到特定的php文件

时间:2013-12-17 16:56:15

标签: php .htaccess mod-rewrite

我试图找出重写规则来将某些网址定向到特定的php文件:

文件是watch.php

网址如下http://mysite/watch/193916/1/watch-skysports.html

我想重定向此

http://mysite/watch.php?file=watch/193916/1/watch-skysports.html

我在htaccess文件中的尝试

Options FollowSymLinks
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule watch/(*)/(*)/(*).html match.php?file=$1 [L]
</IfModule>

但它不起作用 nb:mod_rewrite已启用

1 个答案:

答案 0 :(得分:0)

你没有正确的正则表达式。 *不是通配符,而是表示一些字符。试试这个:

Options FollowSymLinks
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^(watch/[0-9]+/[0-9]+/.*\.html)$ /match.php?file=$1 [L]
</IfModule>