簡體   English   中英

htaccess RewriteRule 生成 url 有 2 個參數以任意順序

[英]htaccess RewriteRule generate url with 2 parameters in any order

我有這個帶有 2 個參數的 url

https://mywebsite.com/folder/subfolder/page.php?id=999&title=this-is-a-test

我需要一個規則來生成以下 url

https://mywebsite.com/page/this-is-a-test-999/

我試過這個規則

RewriteEngine On
RewriteRule ^page/([^-]*)-([^-]*)/$ /folder/subfolder/page.php?&id=$1&title=$2 [L]

我得到了這個 url

https://mywebsite.com/page/999-this-is-a-test/

我需要在規則中做哪些更改才能獲得

this-is-a-test-999

代替

999-this-is-a-test

知道如何解決嗎?

試試這個規則( /page/this-is-a-test-999/ <> /folder/subfolder/page.php?&id=999&title=this-is-a-test )

RewriteEngine On
RewriteRule ^page\/(.*)-(\d+)\/$ /folder/subfolder/page.php?&id=$2&title=$1 [L]

暫無
暫無

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

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