pintee Posted May 7, 2013 Share Posted May 7, 2013 I was wondering if anyone know how to achieve this.I have an index.php that loads a file page.php into a div using jQuery. This page.php has a link that when you click it loads page2.php into the same div(so the url always stays as index.php).I want to make it so that, if you open the link on page.php in a new tab or window, instead of loading page2.php, it redirects to index.php(with page.php in the div). Same if you type in the link to page2.php directly into the browser. Quote Link to comment Share on other sites More sharing options...
requinix Posted May 7, 2013 Share Posted May 7, 2013 Include a special flag in the AJAX URL so you know the request is coming from the AJAX and not a normal request. If it's not present then redirect. By the way, what you're doing is horrible. How am I supposed to bookmark a page on your site? Link it to friends? Search engines will absolutely hate it. Quote Link to comment Share on other sites More sharing options...
pintee Posted May 7, 2013 Author Share Posted May 7, 2013 Sorry requinix, I am still new to AJAX and php. Any chance I could get a snippet of code? Quote Link to comment Share on other sites More sharing options...
requinix Posted May 8, 2013 Share Posted May 8, 2013 Change your AJAX URL to something like /page2.php?ajaxthen redirect if !isset($_GET["ajax"]). Yes, it does mean that someone could go to "page2.php?ajax" to see the page without a redirection, but it is not possible to strictly allow AJAX only - this is basically as close as you can get. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.