dongnong3019 2014-02-13 17:13
浏览 23

网址重写的新手问题

I have few questions and I need your advice. So I'm building mini CMS system where users submit content and I construct an url from their content's headline and id e.g. "74/my-name-is-john-stewart" and insert it to DB besides original context. When I retrieve data with GET method deal?url=74/my-name-is-john-stewart I wonder how to convert that link to deal/74/my-name-is-john-stewart format like in Stackoverflow. And I have doubts if it's a proper way, cause when user deletes id number part, different content is loaded, but url's title part stays the same. I'm afraid , maybe it might cause some SEO problems in the future?

  • 写回答

1条回答 默认 最新

  • dongta1824 2014-02-13 17:25
    关注

    You can use these rules in /deal/.htaccess:

    RewriteEngine On
    RewriteBase /deal/
    
    RewriteCond %{THE_REQUEST} \s/+(deal)\?url=([^\s&]+) [NC]
    RewriteRule ^ /%1/%2? [R=302,L]
    
    # internal forward from pretty URL to actual one
    RewriteRule ^([^/.]+)/?$ ?q=$2 [L,QSA,NC]
    
    评论

报告相同问题?

悬赏问题

  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度
  • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测
  • ¥15 ETLCloud 处理json多层级问题
  • ¥15 matlab中使用gurobi时报错
  • ¥15 这个主板怎么能扩出一两个sata口
  • ¥15 不是,这到底错哪儿了😭
  • ¥15 2020长安杯与连接网探
  • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么