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

时间:2022-06-13 11:18:11

i am trying to figure ou ta rewrite rule to direct certain urls to to specific php file:

我试图计算你重写规则,以将某些网址指向特定的php文件:

the file is watch.php

该文件是watch.php

the urls are like this http://mysite/watch/193916/1/watch-skysports.html

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

i want to redirect this

我想重定向这个

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

my try in the htaccess file

我尝试在htaccess文件中

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

but it doesnt work nb:mod_rewrite is enabled

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

1 个解决方案

#1


0  

You don't have the right regex. The * isn't a wildcard, it's to indicate some number of characters. Try this instead:

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

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

#1


0  

You don't have the right regex. The * isn't a wildcard, it's to indicate some number of characters. Try this instead:

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

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