开发者

.htaccess redirect unless in iframe

When creating websites, I like to let my clients view the work in progress. At the moment I do this by uploading their website to a directory, and use .htaccess to password protect that directory. But keeping track of passwords and ensuring the directory is still protected after an update is becoming an issue.

I have now created a user login system for my clients where they can login and be redirected to a preview of their site (in an iframe on the page preview.php?c=clientName).

I have looked into various ways of redirecting the client site to the preview p开发者_开发知识库age and the easiest has been using .htaccess, but this redirect still affects the site when in an iframe.

Is there any way to stop the .htaccess redirect when the site is in an iframe?


You could test against the "Referer" header, you can't really rely on that but it's the best possible.

E.g. http://jsfiddle.net/QmnKR/

one of the headers will be Referer: http:// fiddle.jshell.net/QmnKR/show/light/

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜