
我已經嘗試了一切,但似乎無法把事情做好:(我有超過 800 個網址,我需要重寫它們以指向一個簡單的 pdf 文件。目前,我有以下鏈接:
http://subdomain.mydomain.com/?type=pdf&id=id123
http://subdomain.mydomain.com/?type=epub&id=id123
我需要這個:
http://subdomain.mydomain.com/pdf/id123.pdf
http://subdomain.mydomain.com/epub/id123.epub
我已經通讀了 htaccess 和 rewriterule 參考頁面,但我仍然遺漏了一些東西。我無法刪除結尾字串 (?type=pdf&id=id123)
這就是我所擁有的:
RewriteCond %{QUERY_STRING} ^type=pdf&id=(.*)$
RewriteRule /?$ pdf/%1.pdf
當然它錯誤地輸出:
http://subdomain.mydomain.com/pdf/id1234.pdf?type=pdf&id=id123
我無法擺脫?型別=pdf&id=id123在最後
任何正確方向的幫助將不勝感激。
答案1
嘗試添加標誌查詢字串丟棄 [QSD]
:
RewriteRule /?$ pdf/%1.pdf [QSD]