3

I have htacess code that redirects

http://website.com:352/pictures/1 to another page. 

I would like to prevent this redirect if the request is in iframe src. Is this possible?

<iframe src="http://website.com:352/pictures/1" style="border: none; width:100%; height:1100px;"></iframe>
6
  • 1
    The server doesn't care if its an iframe or not, htaccess is sending it on its way. If you find a solution later down the line while being able to keep the code in the htaccess, please answer your own question as this sounds like a neat one Commented Sep 26, 2015 at 6:52
  • Somewhat relevant to your need, but as source says, not reliable -> stackoverflow.com/questions/4500939/… Commented Sep 26, 2015 at 6:53
  • 1
    I just read what you linked for referer. How could it be applied in this case? Commented Sep 26, 2015 at 6:54
  • The Referrer is an absolutely unreliable variable. Forget that it exists. Commented Sep 26, 2015 at 9:33
  • This would be easiest to solve, if you appended a query string to your iframe src, such as http://website.com:352/pictures/1?noredirect, and then checked for the existence of that value in the query string before doing the rewriting, via a RewriteCond before your RewriteRule. Commented Sep 26, 2015 at 9:35

1 Answer 1

0

You can do that by adding a request header to the request and then check in your htaccess file for that header and make the redirect if the header does not exist.

However, to add a request header to the iframe, you need to make a workaround by creating AJAX request that and appending the results to the iframe You can check this answer that explains how to do that: How to set custom http headers when changing iframe src?

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.