我知道這是一個非常常見的問題,但我似乎找不到任何關于我的問題的解決方案。檔案夾結構如下所示:
- rootProject
- subfolder
* .htaccess
* index.php
普通網址引數:http://website.com/subfolder/?dynamicKey=dynamicValue. 但我想要實作的是這樣的:http://website.com/subfolder/dynamicKey/dynamicValue
但我沒有這樣做,我只能檢索dynamicKey.
這是我目前的htaccess:
RewriteEngine On
RewriteRule ^([a-z] )/?$ index.php?$1 [NC,QSA,L]
uj5u.com熱心網友回復:
感謝@Ar Rakin。這是解決方案。
RewriteEngine On
RewriteRule ^([a-z] )/?$ index.php?$1 [NC,QSA,L]
RewriteRule ^([a-z] )/([a-z] )/?$ index.php?$1=$2 [NC,QSA,L]
uj5u.com熱心網友回復:
使用您顯示的示例和嘗試的代碼,請嘗試遵循 htaccess 規則。我們需要在重寫規則之前添加條件檢查,否則稍后它也會影響您現有的頁面。
確保在測驗 URL 之前清除瀏覽器快取。
RewriteEngine On
##Added conditions if non-existing pages requested then only perform rewrite.
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([a-z] )/?$ index.php?$1 [NC,QSA,L]
##Added conditions if non-existing pages requested then only perform rewrite.
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([a-z] )/([a-z] )/?$ index.php?$1=$2 [NC,QSA,L]
注意:您使用的正則運算式[a-z]將僅匹配 uri 中的小寫字母,以防它需要檢查任何字母(大寫或小寫),然后在上述規則中[a-z]TO[a-zA-Z]
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/418324.html
標籤:
上一篇:用于熱鏈接保護的Wordpress.htaccess不顯示Woocommerce電子郵件影像
下一篇:基于R中具有多個條件的組過濾行
