dongyi1996 2018-07-14 09:38
浏览 39

没有slug的URL重写(我正在使用API​​)

I am trying to rewrite a URL of example.com/movies/movie.php?id=12345 to something like example.com/movies/spider-man-homecoming for example.

The issue is that all my data is provided through an API and nothing is stored on my server. As the only data I have is the ID. I have access to the .htaccess but not any other configuration files (as it is shared hosting) - I can of course change any of the files like movie.php or create a new file - if necessary.

Is it still possible to rewrite a URL like that somehow?

  • 写回答

1条回答 默认 最新

  • duandong7980 2018-07-14 10:33
    关注

    it is possible but I don't recommend doing it. You could write some middleware or just some script that will match the url request to the id. Maybe something like:

    request url -> use rewrite to pass it to some php file -> inside do data request and match the url to the the retrieved data.

    It has massive setback like, data request time needed added to the response request, not to mention match processing time. I guess network traffic will be your bottleneck.

    评论

报告相同问题?

悬赏问题

  • ¥15 微信会员卡接入微信支付商户号收款
  • ¥15 如何获取烟草零售终端数据
  • ¥15 数学建模招标中位数问题
  • ¥15 phython路径名过长报错 不知道什么问题
  • ¥15 深度学习中模型转换该怎么实现
  • ¥15 HLs设计手写数字识别程序编译通不过
  • ¥15 Stata外部命令安装问题求帮助!
  • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
  • ¥15 TYPCE母转母,插入认方向
  • ¥15 如何用python向钉钉机器人发送可以放大的图片?