hello all
first of all sorry for asking such a stupid kind of question.
i want to know is there a way i can restrict a html page to open up from the website unless an until it is called from other page from my website.


for example there are 2 pages on my website like html1.html and html2.html
i want html2.html should only open up if its called from html1.html other wise not.

thanks

Dani AI

Generated

— the link approach that described handles navigation but does not prevent someone from typing the URL or bookmarking it. As implied, enforcement must happen on the server side; client-side tricks or referrer checks are brittle and can be bypassed or omitted by browsers.

A simple, reliable pattern is to set a server-side flag when the first page is reached and check that flag on the second page. Example (PHP) for the protected page:

<?php
session_start();
if (empty($_SESSION['allow_html2'])) {
    header('Location: html1.html');
    exit;
}
// protected content here
unset($_SESSION['allow_html2']); // optional: make access one-time
?>

The originating page should create that session value before emitting the navigation link (pages must be served by a server-side engine, e.g., renamed to .php or routed to a script). An alternative is a single-use token: generate a random token on page1, store it server-side, include it in a form POST or short-lived query value, and validate & consume it on page2. Tokens avoid simple bookmarking; prefer POST or session-backed tokens to reduce exposure in logs and referer headers.

Important cautions: HTTP Referer is not reliable or secure (can be absent or spoofed). Any purely client-side check (JavaScript) is trivial to bypass. Sessions require cookies (or another session transport). For truly sensitive content, require authentication and server-side authorization rather than trying to gate content by “where it came from.” If hosting is static-only (no server-side code), strong restriction is not possible — use protected hosting or an authentication layer.

Recommended Answers

All 4 Replies

It is very easy, don't hesitate to ask questions

<snipped>

hello all
first of all sorry for asking such a stupid kind of question.
i want to know is there a way i can restrict a html page to open up from the website unless an until it is called from other page from my website.


for example there are 2 pages on my website like html1.html and html2.html
i want html2.html should only open up if its called from html1.html other wise not.

thanks

...basically, you can use a hyperlink to locate the link you want to access. Just use the code <a href="html2.html">/*your text here*/</a>

...basically, you can use a hyperlink to locate the link you want to access. Just use the code <a href="html2.html">/*your text here*/</a>

right now i am doing a hyper link only like
in html1.html
i have added as
<a href="html2.html"><font size=-3 align=center>Click here</font></a>

but i want if some directly open html2.html from web browser it should not open up or should go back to html1.html

I see that no one has responded to this for some time. I know of no simple way to do what you're asking without using Perl or another other language to do a referrer check before rendering the page.

I am not aware of any method of doing this within html alone and doubt it is possible.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.