dseve40868 2015-05-26 20:37
浏览 146
已采纳

如何重写包含参数的URL?

If user access this URL(http://domain.com/products/view-product.php?productID=21) in browser, it should show the page http://domain.com/new/view-product.php?pID=21

I have tried bellow code but it wont working, so please help me to resolve.

RewriteCond %{REQUEST_FILENAME} -f 
RewriteCond %{THE_REQUEST} products/view-product.php 
RewriteRule ^products/view-product.php?productID=21$ new/view-product.php?pID=21 [R=301,L]

products/view-product.php are physically exists in the server, still i want to rewrite it to the new page that i have designed now.

  • 写回答

3条回答 默认 最新

  • douci1615 2015-05-26 20:43
    关注

    You can't match against the query string (everything after the ?) in a rewrite rule. Only the URI is used to match against that regular expression. You need to use the condition:

    RewriteCond %{REQUEST_FILENAME} -f 
    RewriteCond %{THE_REQUEST} products/view-product.php\?productID=21($|\ |&)
    RewriteRule ^products/view-product.php$ /new/view-product.php?pID=21 [R=301,L]
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 从Freecad中宏下载的DesignSPHysics,出现如下问题是什么原因导致的(语言-python)
  • ¥30 notepad++ 自定义代码补全提示
  • ¥15 MATLAB有限差分法解一维边值问题
  • ¥200 内网渗透测试 横向渗透 Windows漏洞 Windows权限维持
  • ¥15 数据结构图的相关代码实现
  • ¥15 python中aiohttp.client_exceptions.ContentTypeError
  • ¥30 DeepLung肺结节检测生成最大froc值对应的epoch报错
  • ¥15 信号发生器如何将频率调大,步尽值改成10
  • ¥15 keil 5 编程智能家具,风扇台灯开关,人体感应等
  • ¥100 找一名渗透方面的专家