dongyi1748 2015-07-17 02:29
浏览 11

基于asp查询重写asp到php

I have seen several questions similar and tried all solutions but at a loss. I need to redirect

example.com/products.asp?lob=health

to

example.com/services/healthcare/

I need to do this for several lob=different value. Is there a way I can redirect each url. Maybe do some kind of rewrite condition on lob but if the value of lob = health, redirect here. If it equals home, redirect somewhere else?

  • 写回答

2条回答 默认 最新

  • dousi1970 2015-07-17 03:42
    关注

    Not sure this is the "correct" way to do it but it works.

    RewriteCond %{QUERY_STRING} ^lob=value1$ [NC]
    RewriteRule ^products.asp$ http://example.org/sample/one/? [R=301,L]
    

    And then for a different value:

    RewriteCond %{QUERY_STRING} ^lob=value2$ [NC]
    RewriteRule ^products.asp$ http://example.org/sample/two/? [R=301,L]
    

    And then for everything that doesn't match a value:

    RewriteRule ^products\.asp$ [insert new url here] [R=301,L]
    

    The last example also works if you just want to redirect a .asp url to .php. Keep in mind that I have other conditions and rules that are removing the .php extension and adding a / to all files:

     RewriteCond %{REQUEST_FILENAME} !-f
     RewriteRule ^([^/]+)/$ $1.php
     RewriteRule ^([^/]+)/([^/]+)/$ /$1/$2.php
     RewriteCond %{REQUEST_FILENAME} !-f
     RewriteCond %{REQUEST_FILENAME} !-d
     RewriteCond %{REQUEST_URI} !(\.[a-zA-Z0-9]{1,5}|/)$
     RewriteRule (.*)$ /$1/ [R=301,L]
    
    评论

报告相同问题?

悬赏问题

  • ¥15 神经网络怎么把隐含层变量融合到损失函数中?
  • ¥30 自适应 LMS 算法实现 FIR 最佳维纳滤波器matlab方案
  • ¥15 lingo18勾选global solver求解使用的算法
  • ¥15 全部备份安卓app数据包括密码,可以复制到另一手机上运行
  • ¥15 Python3.5 相关代码写作
  • ¥20 测距传感器数据手册i2c
  • ¥15 RPA正常跑,cmd输入cookies跑不出来
  • ¥15 求帮我调试一下freefem代码
  • ¥15 matlab代码解决,怎么运行
  • ¥15 R语言Rstudio突然无法启动