471,887 Members | 739 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,887 software developers and data experts.

Hide Url

Hi all,
I would like to hide my url to other for secuiry purpose.

i have page like:


i dont want to show my users the page extension.i want to show my user:


how can i do this?
Sep 20 '06 #1
7 27077

U do this with the help of .htaccess concept.

U have to define rule that if url is


then its give url http://localhost/cstc/.

Plz. try to use .htaccess concept

Sep 20 '06 #2
I have an option for you..
just replace your url by duplicate url
STEP1 -> take the current url by $_SERVER['PHP_SELF']


Sep 20 '06 #3
here is the code for an .htaccess file to do what youre asking:
Expand|Select|Wrap|Line Numbers
  1. RewriteEngine On
  2. RewriteBase /
  3. RewriteCond    %{REQUEST_FILENAME}  !-f
  4. RewriteCond    %{REQUEST_FILENAME}  !-d
  5. RewriteRule . /index.php [L]
this turns on the mod_rewrite engine in apache, tells what base directory to look in, checks the files to see if they exist, and if they dont, it will default to /index.php and you can use the URL as variable using $_SERVER['REQUEST_URI'] and explode

youll need to do this for each directory you want to have work, otherwise they will all go back to /index.php

good luck,
Sep 23 '06 #4

i am working under windows environment and i am novice in php. i am using apche2traid to run my apache server. i could not catch ur solutions. can anyone help me giving the whole sample code?
Sep 23 '06 #5
http://php.net/htaccess to learn about this in php
http://us2.php.net/reserved.variables and find info on REQUEST_URI

since you are using windows, you cant create a .htaccess file because windows wont allow a file starting with a period. so you need to edit your apache.conf file to look for a different file name than .htaccess.

now that that is ready, creat that file with the info i put in my last post. if your apache document root is c:/php/ then in the .htaccess the / will point to that.

so what the htaccess file does is turns on apache mod_rewrite, and tells it that if the file in the URI doesnt exist (eg: http://localhost/fakedirectory ), it will display your index.php for your document root. if you HAVE a directory called 'fakedirectory', it will show the index.php file for that directory. you can place an htaccess file in fakedirectory as well, and start stacking them up so it wouldnt go back to your document root.

back to using mod_rewrite...

if you have it point back to / and you go to http://localhost/fakedirectory, it will show /index.php and will set the variable $HTTP_SERVER_VARS['REQUEST_URI'] to /fakedirectory. if you went to http://localhost/fakedirectory/anotherfake it would set $HTTP_SERVER_VARS['REQUEST_URI'] to /fakedirectory/anotherfake, which you can then call and explode to break it at the / into seperate vars to work with.

sorry this is wordy, but i dont know how it cant be

Sep 23 '06 #6
Hi guys,
thanks for ur solutions. i got another way to solve the problem. below codes also work. just save the code as index.htm and keep it in the folder. the page name will not show. dont remove the index.php file.

best regards.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN"
<TITLE>Customer Enquiry</TITLE>
<FRAMESET cols="100%">
<FRAME src="http://localhost/cust/index.php">
<P>This frameset document contains:
<LI><A href="http://localhost/cust/">A link to mysite</A>
Sep 24 '06 #7
your html link:
Expand|Select|Wrap|Line Numbers
  1. <a href="www.example.com/item/harddisk">Hard disk</a>
Your .htaccess
Expand|Select|Wrap|Line Numbers
  1. RewriteRule ^item/(.*)$ products.php?name=$1
Your products.php
Expand|Select|Wrap|Line Numbers
  1. $name=$_GET['name']
Jan 10 '14 #8

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

3 posts views Thread by alex | last post: by
7 posts views Thread by FP | last post: by
5 posts views Thread by ali | last post: by
6 posts views Thread by Ralph | last post: by
6 posts views Thread by Doogie | last post: by
2 posts views Thread by richard | last post: by
reply views Thread by YellowAndGreen | last post: by
reply views Thread by zermasroor | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.