469,270 Members | 1,153 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,270 developers. It's quick & easy.

Hide Url

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

i have page like:

http://localhost/cstc/index.php

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

http://localhost/cstc/

how can i do this?
Sep 20 '06 #1
7 26546
Hello,

U do this with the help of .htaccess concept.

U have to define rule that if url is

http://localhost/cstc/index.php

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

Plz. try to use .htaccess concept

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

STEP2 -> AND REPLACE IT BY YOUR URL(WHICH U LIKE)

bye
pasu
Sep 20 '06 #3
tbb9216
16
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]
  6.  
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,
-tim
Sep 23 '06 #4
mainul
51
Hi,

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
tbb9216
16
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

-tim
Sep 23 '06 #6
mainul
51
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"
"http://www.w3.org/TR/html4/frameset.dtd">
<HTML>
<HEAD>
<TITLE>Customer Enquiry</TITLE>
</HEAD>
<FRAMESET cols="100%">
<FRAME src="http://localhost/cust/index.php">
<NOFRAMES>
<P>This frameset document contains:
<UL>
<LI><A href="http://localhost/cust/">A link to mysite</A>
</UL>
</NOFRAMES>
</FRAMESET>
</HTML>
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
By using this site, you agree to our Privacy Policy and Terms of Use.