簡體   English   中英

重寫多個參數.htaccess

[英]rewrite multiple parameters .htaccess

我需要將www.sample.com/user/john/重寫為www.sample.com/user/?u=john

僅當我省略結尾的/"www.sample.com/user/john“時,此代碼才有效。如何使它也像” www.sample.com/user/john/“一樣工作?

RewriteRule ^([A-Za-z0-9 _] +)$ index.cfm?u = $ 1 [L]

現在我需要它進一步發揮作用

www.sample.com/user/john/23564/重寫為“ www.sample.com/user/?u=john&i=23564”

一件事“ www.sample.com/user/john”即使沒有/ 23564 /

謝謝

添加可選的斜杠(以及URL的“ user /”部分):

RewriteRule ^user/([A-Za-z0-9_]+)/?$ index.cfm?u=$1 [L]

下一步:

RewriteRule ^user/([A-Za-z0-9_]+)(/([0-9]+))?/?$ index.cfm?u=$1&i=$3 [L]

暫無
暫無

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

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