簡體   English   中英

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

[英]mod_rewrite: RewriteRule redirect certain urls to specific php file

我試圖找出重寫規則以將某些URL定向到特定的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已啟用

您沒有正確的正則表達式。 *不是通配符,它​​表示一些字符。 嘗試以下方法:

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM