htaccess的:我怎样才能保持相同的URL,但在服务器上显示一个不同的页面 [英] .htaccess: How can I keep the same the URL, but display a different page on the server

查看:176
本文介绍了htaccess的:我怎样才能保持相同的URL,但在服务器上显示一个不同的页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我怎么能保持相同的URL,但会显示使用的.htaccess重写规则的服务器上的不同页面? 我工作的防盗链。播放列表与下面的链接生成的:<?code> http://site.com/get.playlist.php

中的完整链接:

<$p$p><$c$c>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
 

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

解决方案

这会是这样的:

 重写规则^视频/(\ w +)/(\ w +)/(\ w +)$ http://site-1.com/get.playlist.php?playlist=http ://site.com/video/$1/$2/$3&哈希= $ 1
 

尽管这可能会导致一个无效的网址,你需要给url EN $ C C字符$如 / 的查询字符串。

这是另一个问题是,重定向是不同的域,所以链接将在浏览器的地址栏可能发生变化。

难道真的在不同的领域,因为你的问题的标题似乎暗示,否则?

如果没有,你可以将其更改为:

 重写规则^视频/(\ w +)/(\ w +)/(\ w +)$ /get.playlist.php?playlist=http://site.com/video/ $ 1 / $ 2 / $ 3和散列= $ 1
 

How can I keep the same the URL, but display a different page on the server using .htaccess rewrite rule? I'm working on hotlink protection. The playlist is generated with the following link: http://site.com/get.playlist.php?

the full link:

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

i would like to redirect the link from

http://site-2.com/video/34141ce7760f58f0c3eb5e0c758afb69/pl/playlist.txt

to

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

解决方案

That would be something like:

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

Although that would probably result in an invalid url, you would need to url encode the characters like : and / in the query string.

An additional problem is that the redirect is to a different domain, so the url would probably change in the browser address bar.

Is it really on a different domain, as your question title seems to imply otherwise?

If not, you can change it to:

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

这篇关于htaccess的:我怎样才能保持相同的URL,但在服务器上显示一个不同的页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆