我想使用.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