.htaccess redirect unless in iframe

会有一股神秘感。 提交于 2019-12-12 17:27:45

问题


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 page 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?


回答1:


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/



来源:https://stackoverflow.com/questions/4500939/htaccess-redirect-unless-in-iframe

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!