真正的網址 -subdomain.example.com?id=3&s=lorem-ipsum
想要 -subdomain.example.com/3/lorem-ipsum
這是我的嘗試:
RewriteEngine ON
RewriteCond %{THE_REQUEST} \?id=([^&]*)&s=([^\s&]*) [NC]
RewriteRule ^ /%1/%2? [R=301,L]
結果 - 想要的網址在那里,但瀏覽器顯示 404 錯誤 - 未找到
請幫助
uj5u.com熱心網友回復:
您收到錯誤訊息,因為 您的服務器上不存在404重定向的 URL 。subdomain.example.com/3/lorem-ipsum要解決此問題,您需要將此新的 URL 格式映射到其原始位置subdomain.example.com?id=3&s=lorem-ipsum。
RewriteEngine ON
RewriteCond %{THE_REQUEST} \?id=([^&]*)&s=([^\s&]*) [NC]
RewriteRule ^ /%1/%2? [R=301,L]
#map new URL to the old one
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^/] )/(. )$ /?id=$1&s=$2 [L]
轉載請註明出處,本文鏈接:https://www.uj5u.com/qiye/411221.html
標籤:
上一篇:URL在htaccess中的FallbackResource上不起作用
下一篇:將檔案夾重寫為子檔案夾
