簡體   English   中英

如何創建適用於urlencoded值的Apache mod_rewrite規則?

[英]How do I create an Apache mod_rewrite rule that works with urlencoded values?

我正在使用php函數urlencode http://php.net/manual/en/function.urlencode.php編碼GET參數$_GET['test']

我想使用apache重寫規則將website.com/%CE%A6 URL重寫為website.com/index.php?test=%CE%A6

RewriteRule ^([a-z0-9])/?$ /index.php?test=$1 [NC,L]

什么是可以代替[a-z0-9]接受urlencode函數返回的有效字符范圍的正則表達式?

您可以捕獲任何東西,直到獲得帶有RewriteCond/以防止循環為止:

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+)/?$ index.php?test=$1 [QSA,L]

暫無
暫無

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

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