在下面有一些問題;特別是第一條規則。
^pages/articles/marketArticles\.php?id=31我認為這是問題所在,所以基本上我想要實作的是,當用戶訪問時/pages/articles/marketArticles.php?id=31,用戶被重定向/01-02-2022/Top-5-Digital-Assets-to-watch-out-for-in-2022/到此規則必須使用多個不同的 id。
RewriteRule ^pages/articles/marketArticles\.php?id=31 /01-02-2022/Top-5-Digital-Assets-to-watch-out-for-in-2022 [R=301,L]
RewriteRule ^01-02-2022/Top-5-Digital-Assets-to-watch-out-for-in-2022/?$ /pages/articles/marketArticles.php?id=31 [END]
有了上面的例子,當用戶去到/01-02-2022/Top-5-Digital-Assets-to-watch-out-for-in-2022/用戶可以查看的頁面。當用戶轉到pages/articles/marketArticles.php?id=31用戶時,會顯示該頁面,但不會重定向到新的 url。
uj5u.com熱心網友回復:
使用您顯示的示例/嘗試,請嘗試遵循 htaccess 規則檔案。確保您的 htaccess 檔案與01-02-2022檔案夾一起駐留(不是在其中,而是在它旁邊)。
請確保在測驗您的 URL 之前清除瀏覽器快取。
RewriteEngine ON
##Rules when user hits /pages/articles/marketArticles\.php?id=31 to redirect TO 01-02-2022/Top-5-Digital-Assets-to-watch-out-for-in-2022/
RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteCond %{THE_REQUEST} \s/pages/articles/marketArticles\.php\?id=31\s [NC]
RewriteRule ^ /01-02-2022/Top-5-Digital-Assets-to-watch-out-for-in-2022? [R=301,L]
##Rules when user hits 01-02-2022/Top-5-Digital-Assets-to-watch-out-for-in-2022 it rewrites to pages/articles/marketArticles.php?id=31 in backend.
RewriteRule ^01-02-2022/Top-5-Digital-Assets-to-watch-out-for-in-2022/?$ /pages/articles/marketArticles.php?id=31 [NC,QSA,L]
轉載請註明出處,本文鏈接:https://www.uj5u.com/yidong/425346.html
