-1

如何保持相同的 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
4

1 回答 1

2

那将是这样的:

 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
于 2012-11-24T21:17:59.037 回答