嗨,我想將下面的 URL 重寫https://example.com/item?id=223為 https://example.com/google/223. 這里會動態生成ID
我試過這個,但它不起作用
RewriteRule ^google/$ item?id=$1 [R=301,L]
任何幫助將不勝感激?
uj5u.com熱心網友回復:
根據您顯示的嘗試,請嘗試遵循 htaccess 規則。請確保您的 htaccess 規則檔案和 index.php 檔案位于同一檔案夾中。
在測驗您的 URL 之前,請確保清除瀏覽器快取。
RewriteEngine ON
##External redirect in browser to new URL.
RewriteCond %{THE_REQUEST} \s/item\?id=(\d )\s [NC]
RewriteRule ^ /google/%1? [R=301,L]
##Internal rewrite to index.php in backend server.
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^google/(\d )/?$ index.php?id=$1 [QSA,NC,L]
轉載請註明出處,本文鏈接:https://www.uj5u.com/yidong/402248.html
上一篇:按嵌套欄位匹配的百分比對ElasticSearch結果進行排序
下一篇:創建帶有標簽的bash腳本選單
