簡體   English   中英

.htaccess具有3個Get參數的RewriteRule

[英].htaccess RewriteRule with 3 Get parameters

我將用戶.htaccess文件重定向

http://www.example.org/results.php?q=anything&start=0&type=web

http://www.example.org/search/anything/0/web

那可能嗎 ? 目前,我僅使用此RewriteRule重定向q-GET參數:

RewriteRule ^search/(.*)$ results.php?q=$1 [L,QSA]

它仍然有效,但是我不知道要重寫3個Get參數。

RewriteRule ^search/(.*)/(.*)/(.*)$ results.php?q=$1&start=$2&type=$3 [L,QSA]
RewriteRule ^(search)/(.*)/(\d+)/(.*)$ results.php?q=$2&start=$3&type=$4 [L,QSA]

小解釋:

當您使用(.*)進行正則表達式匹配時,可以使用$#獲得匹配的部分,其中#是代表鏈中每個單個匹配位置的增量數字。

  • search/(.*) search/$1
  • search/(.*)/(.*) search/$1/$2
  • search/(.*)/(.*)/(.*) search/$1/$2/$3

暫無
暫無

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

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