weixin_44269976
�50
2019-05-05 18:45
采纳率: 37.5%
浏览 573

Apache 伪静态配置 去掉url中的?号和=号

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

2条回答 默认 最新

  • asdf3301
    asdf3301 2019-05-06 18:58
    已采纳

    0、httpd 2.4

    1、编辑httpd.conf,确认打开了mod_rewrite 模块

    2、配置规则

    <Location "/cn/support/how-to/detail-use-skills/">
    
        RewriteEngine On
        RewriteBase "/cn/support/how-to/detail-use-skills/"
        RewriteRule "^.*/(resourceId)/(.*)$" "?$1=$2" [L]
    
    </Location>
    

    3、访问地址,http://192.168.100.128/cn/support/how-to/detail-use-skills/resourceId/zh-cn00457011

    172.17.0.1 - - [06/May/2019:10:49:05 +0000] "GET /cn/support/how-to/detail-use-skills/?resourceId=zh-cn00457011 HTTP/1.1" 404 234
    192.168.100.1 - - [06/May/2019:10:49:05 +0000] "GET /cn/support/how-to/detail-use-skills/resourceId/zh-cn00457011 HTTP/1.1" 404 234
    

    实际上没有相关的资源所以都是404,但地址是被改写了的

    点赞 评论
  • qq_30635221
    qq_30635221 2019-05-05 21:27

    1.加载Rewrite模块
    2.虚拟主机段添加如下
    RewriteEngine On
    RewriteRule ^/(.+)/detail-use-skills/(.+)$ /$1/detail-use-skills/?resourceId=$2 [L]

    点赞 评论

相关推荐