我想使用.htaccess重寫我的網址。我的舊網址是http://gametesting.in/infocomstudios/gamedetails.php?id=2
,我需要將其更改爲以下http://gametesting.in/infocomstudios/demopage.html
。在我的.htaccess中使用什麼代碼。我試着用下面的代碼:如何編寫.htaccess文件代碼以將舊網址更改爲新網址
RewriteCond %{QUERY_STRING} ^id=2$
RewriteRule ^gamedetails\.php demopage.html [L,R]
但我得到了一個錯誤:
The requested URL /home/gamet/public_html/infocomstudios/demopage.html was not found on this server. Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.
而且我的新網址變爲:http://gametesting.in/home/gamet/public_html/infocomstudios/demopage.html?id=2
請幫我解決這個問題。
這是一個標準的404錯誤。服務器找不到新頁面。可能需要處理?id = 2在html文件中不可接受。 – Linkan
@Linkan感謝您的評論。但實際上我想重寫我的url.so,因此不需要創建該html文件 – Aswathy
規則編寫的方式,您將發送給gamedetails.php?id = 2的人發送給demopage.html ,它必須存在才能工作。 – Linkan