Forum Moderators: mack

Message Too Old, No Replies

How To Hide URL

         

wapture

6:20 pm on Sep 13, 2003 (gmt 0)



I have made my own login script for members of my site. But want to hide the protected pages url.
If not hide it, make sure they cannot enter the protected pages URL into the address bar and view the page without logging in.

How can I do this?

Any help?

moltar

6:31 pm on Sep 13, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



you can use basic authorization.

mcfly

8:50 am on Sep 15, 2003 (gmt 0)

10+ Year Member



Hi Wapture,

Many hosting companies offer password protection of selected files/folders as a part of the hosting control panel. If not, you could try basic authentication, as moltar mentioned, using .htaccess.

Try searching the site for '.htaccess password' for some places to start.

mcfly

davegerard

6:25 am on Sep 25, 2003 (gmt 0)

10+ Year Member



If your using ASP you can set a session variable like Session("UserId"), when the user logs in. Session variables cannot be created from the browser by a visitor to your site.

Then create an include file (SSI or Server Side Include) with some code that checks for Session("UserId"). If it doesn't exist, the user gets bounced to the login page. The reason you put this in an include file is so you don't have to recreate it for every page you need it in. Just include the file in those pages.

In a blank file (save it as authenticate.inc or something), insert the following code. No need for anything else...

<%
response.buffer = true

if Session("UserId") = "" then
MyRedirect = "login.asp"
response.redirect MyRedirect
end if
%>

At the top of your private page, assuming that you saved authenticate.inc in the same directory as the private file...

<!-- #include file="authenticate.inc" -->

If your private page happens to be an include of another page then the include script at the top should be as follows to avoid breaking the inclusion.

<!-- #include virtual="common/authenticate.inc" -->

This is assuming that you saved authenticate.inc in a folder called "common" in your root web. Remember that the page that is using this include file must be an ASP page.