htaccess的,让页面通过重定向被访问,但不是直接 [英] htaccess to allow pages to be visited via a redirect, but NOT directly

查看:72
本文介绍了htaccess的,让页面通过重定向被访问,但不是直接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我原本以为事情设置正确,但我还没有找到一个完美的解决方案相当,但并想看看是否有任何人也做了类似的设置。

I thought I had things set up correctly but I havent found a 'perfect' solution quite yet and wanted to see if anyone out there has done a similar setup.

我有一个网页,根据一周中的一天将重定向到其他网页(它们都没有公开联的)。我不希望用户能够得到最终的页面而不需要通过指定的引用者,使用户不能书签和拉星期一网页上周五。如果他们这样做,他们将被重定向说,他们无法通过书签访问它。

I have a page that depending on the day of the week will redirect to other pages (which are are not publicly linked). I do not want users to be able to get to the final page without going through the designated referer so that users cannot bookmark and pull-up Mondays page on Friday. If they do so they'll be redirected saying that they cannot access it via a bookmark.

主要页面www.example.com/AB/一旦访问该页面的用户将自动重定向到www.example.com/AB/123或www.example.com/AB/123

The main page is www.example.com/AB/ Upon visiting that page a user is automatically redirected to www.example.com/AB/123 or www.example.com/AB/123

我想做到的是阻止访问的最后几页,如果他们不从父页面引用。父页面,但是,可以从任何地方访问(引荐无所谓)。

What I would like to accomplish is to block access to the final pages if they are not referred to from the parent page. The parent page, however, can be accessed from anywhere (referrer does not matter).

思考?

感谢您!

@olaf - 这里就是我在...

@olaf - Here's where I am at ...

RewriteEngine On
RewriteCond %{HTTP_REFERER} !mysite\.com [NC]
RewriteRule ^/?q/? http://mysite.com/sorry-no-bookmarks/ [R=302,L]

不顾天时间,任何正在一个子页面/ Q / ...应该在mysite.com重定向到无书签页面,如果它不是来自某个地方(任何地方)。另外,我想将你的东西多数民众赞成在subpaged/ N / ...从任何地方自由地访问(包括境外查阅情况)。作品大多没关系铬,但Firefox和IE的百般阻挠的事不管。有趣的时代!

disregarding days or timing, anything that is a subpage under "/q/..." should be redirected to the "no bookmarks" page if it did not come from somewhere (anywhere) on mysite.com. In addition I would like to keep anything thats subpaged under "/n/..." freely accessible from anywhere (outside referers included). Works mostly okay with chrome, but firefox and IE are blocking things regardless. fun times!

推荐答案

既然你留在同一台服务器上,我不会重定向,但做一个内部的重写,而不是

Since you stay on the same server, I wouldn't redirect but do an internal rewrite instead

RewriteEngine on

RewriteCond %{TIME_WDAY} 1
RewriteRule ^AB/?$ /AB/monday.html [L]

RewriteCond %{TIME_WDAY} 2
RewriteRule ^AB/?$ /AB/tuesday.html [L]

# and so on ...

或命名日常文件 1.HTML 周一, 2.HTML 周二,...和这样做有一个原则:

or name the daily files 1.html for monday, 2.html for tuesday, ... and do it in one rule

RewriteEngine on
RewriteRule ^AB/?$ /AB/%{TIME_WDAY}.html [L]

这篇关于htaccess的,让页面通过重定向被访问,但不是直接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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