duanlu5055 2016-07-26 06:47
浏览 10

使用htaccess [duplicate]将%20更改为 -

This question already has an answer here:

i've an index.php page & have some posts on that.when read more button is clicked the user is redirected to all.php which contains full post.actually,the url on all.php lokks like this

http://localhost/project/all.php?rm=How%20to%20create%20jQuery%20Popup

i want to change %20 to -. is there anyway to do this with htaccess.?

</div>
  • 写回答

1条回答 默认 最新

  • douxiawei9318 2016-07-26 06:49
    关注
    RewriteEngine On
    RewriteBase /
    
    # external redirect from actual URL to pretty one (remove query string)
    RewriteCond %{THE_REQUEST} \s/+content\.php\?page=([^\s&]+) [NC]
    RewriteRule ^ %1? [R=302,L,NE]
    
    # convert all space (%20) to hyphen
    RewriteRule "^(\S*) +(\S* .*)$" $1-$2 [N,NE]
    RewriteRule "^(\S*) (\S*)$" $1-$2 [L,R=302,NE]
    
    # rewrite rule to call actual PHP handler
    RewriteRule ^([^./]+)\.html$ content.php?page=$1 [L,QSA,NC]
    
    评论

报告相同问题?

悬赏问题

  • ¥20 我想使用一些网络协议或者部分协议也行,主要想实现类似于traceroute的一定步长内的路由拓扑功能
  • ¥30 深度学习,前后端连接
  • ¥15 孟德尔随机化结果不一致
  • ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
  • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
  • ¥15 谁有desed数据集呀
  • ¥20 手写数字识别运行c仿真时,程序报错错误代码sim211-100
  • ¥15 关于#hadoop#的问题
  • ¥15 (标签-Python|关键词-socket)
  • ¥15 keil里为什么main.c定义的函数在it.c调用不了