【问题标题】:.htaccess: How can I keep the same the URL, but display a different page on the server [closed].htaccess:如何保持相同的 URL,但在服务器上显示不同的页面 [关闭]
【发布时间】:2012-11-12 17:51:49
【问题描述】:

如何保持相同的 URL,但使用 .htaccess 重写规则在服务器上显示不同的页面? 我正在研究热链接保护。播放列表通过以下链接生成:http://site.com/get.playlist.php?

完整链接:

http://site-1.com/get.playlist.php?playlist=http://site.com/video/34141ce7760f58f0c3eb5e0c758afb69/pl/playlist.txt&hash=34141ce7760f58f0c3eb5e0c758afb69

我想从

重定向链接
http://site-2.com/video/34141ce7760f58f0c3eb5e0c758afb69/pl/playlist.txt

http://site-1.com/get.playlist.php?playlist=http://site.com/video/34141ce7760f58f0c3eb5e0c758afb69/pl/playlist.txt&hash=34141ce7760f58f0c3eb5e0c758afb69

【问题讨论】:

  • 你认为再次问同样的问题会得到更多的结果?
  • 我已将上一个问题标记为删除

标签: php linux apache .htaccess nginx


【解决方案1】:

应该是这样的:

 RewriteRule ^video/(\w+)/(\w+)/(\w+)$ http://site-1.com/get.playlist.php?playlist=http://site.com/video/$1/$2/$3&hash=$1

虽然这可能会导致 url 无效,但您需要对查询字符串中的 :/ 等字符进行 url 编码。

另一个问题是重定向到不同的域,因此浏览器地址栏中的 url 可能会发生变化。

它是否真的在不同的域上,因为您的问题标题似乎暗示了其他方面?

如果没有,可以改成:

 RewriteRule ^video/(\w+)/(\w+)/(\w+)$ /get.playlist.php?playlist=http://site.com/video/$1/$2/$3&hash=$1

【讨论】:

  • 我认为是时候使用 modrewrite.stackexchange.com。
猜你喜欢
  • 1970-01-01
  • 2014-09-04
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-01-02
  • 2013-10-16
  • 2016-03-29
相关资源
最近更新 更多