dsovc00684 2013-03-22 09:33
浏览 16

Php Prefix Post Change

In my website people can post videos and pictures. All posts are in this format

domain.com/gag/02938482

How can I change the prefix of a post, instead of gag to have p for example.

  • 写回答

1条回答 默认 最新

  • dongzhui4927 2013-03-22 09:40
    关注

    Make sure you have RewriteEngine on in the .htaccess file

    RewriteEngine on                                 # Turns the rewrite engine on
    RewriteRule ^gag/([^/.]+)/?$ view.php?pid=$1 [L] 
    
    • ^ start of the string to rewrite
    • gag/
    • ( start of capturing a variable
    • [ start of a character group
    • ^/. anything not equal to / with any character behind it (.)
    • ] end of a character group
    • + one or more of the character(group)
    • ) end of capturing a variable
    • /? zero or more slashes
    • $ end of the string to rewrite
    • view.php?pid= string after rewriting
    • $1 variable 1 (captured with the () )
    • [L] last rule to rewrite
    评论

报告相同问题?

悬赏问题

  • ¥15 帮我写一个c++工程
  • ¥30 Eclipse官网打不开,官网首页进不去,显示无法访问此页面,求解决方法
  • ¥15 关于smbclient 库的使用
  • ¥15 微信小程序协议怎么写
  • ¥15 c语言怎么用printf(“\b \b”)与getch()实现黑框里写入与删除?
  • ¥20 怎么用dlib库的算法识别小麦病虫害
  • ¥15 华为ensp模拟器中S5700交换机在配置过程中老是反复重启
  • ¥15 java写代码遇到问题,求帮助
  • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
  • ¥15 有了解d3和topogram.js库的吗?有偿请教