By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,952 Members | 959 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,952 IT Pros & Developers. It's quick & easy.

How to hide file name from URL?

kamill
P: 71
I need to hide name of web pages from URL, I need to show only domain name of web site, and want to hide the name of web pages after slash.
Example
insteade of www.mysiteabc.com/anyfile.php, i need to show only www.mysiteabc.com.
Thanking in advance.

Regards:
Kamill
May 14 '07 #1
Share this Question
Share on Google+
5 Replies


pbmods
Expert 5K+
P: 5,821
I need to hide name of web pages from URL, I need to show only domain name of web site, and want to hide the name of web pages after slash.
Example
insteade of www.mysiteabc.com/anyfile.php, i need to show only www.mysiteabc.com.
I'm afraid that's not possible. If a script could change the text in the location bar in a User's browser, you could create a pharming page that looks like, for example, eBay.com's login page and then change the location bar text to eBay's login URL.

Without looking at the source, nobody would be able to tell that the site was a phony.

Now, one option you do have is to create a landing page from which you could obfuscate your page names. Something like this:

landing.php
Expand|Select|Wrap|Line Numbers
  1. switch($_GET['page']) {
  2.     case '001':
  3.         include('/pages/home.php');
  4.         break;
  5.  
  6.     case '002':
  7.         include('/pages/search.php');
  8.         break;
  9.  
  10.     .
  11.     .
  12.     .
  13.  
  14.     default:
  15.         include('/pages/404.php');
  16.         break;
  17. };
  18.  
Note that you can even store the source files outside of your document root (such as in the example above) to prevent Users from accessing your source files directly.

E.g., to get to the homepage, a User would have to go to:
http:// mysiteabc.com/landing.php?page=001
May 15 '07 #2

P: 93
You can kind of hide file names by using folders instead.

So instead of www.mysite.com/myfile.php
use
www.mysite.com/myfolder

Then in myfolder name your file index.html. If it needs to be a php file then you can change your webserver to treat .html as .php. (If you're using Apache it's something called 'Apache file handlers'.) It doesn't really make any difference to your other .html files because if php doesn't find any <?php tags ?> in the file then it will just treat it as html. Or you could set your webserver to treat .htm files as php but treat .html as html.

I hope that helps (though it probably doesn't!!)
May 15 '07 #3

shidec
P: 26
it can be tricked.
Use frame !!!
I got this ideas from phpPgAdmin,
but with small correction

Main frame (index.html):
Expand|Select|Wrap|Line Numbers
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  5. <title>Sistem Informasi Pembayaran - Universitas Negeri Yogyakarta</title>
  6. </head>
  7. <frameset rows="*,0" frameborder="no" border="0" framespacing="0">
  8.   <frame src="index.php" name="mainFrame" id="mainFrame" />
  9.   <frame src="dummy.html"></frameset>
  10. <noframes><body>
  11. </body>
  12. </noframes></html>
  13.  
Make sure your web server call index.html first than index.php
in apache, it can be configured at httpd.conf

dummy.html is an empty .html page

Add this script to the real pages (ex: index.php),
better put it in one .js file that can be called from all pages.
Expand|Select|Wrap|Line Numbers
  1. function cekParent(){
  2.     if(top.mainFrame==null){
  3.         window.open("/","_top");
  4.     }
  5. }
  6.  
function of that script is call main frame if user try to call index.php directly.
address bar will only show www.yourdomain.com
May 16 '07 #4

100+
P: 136
Hi,

hiding the page name from URL is not a good option to follow. I prefer u should change file name. But the process of doing is bit complex one. All u need to do is to use a common script to modify the file name in that comes in the request and call the script from .htaccess. I forgot to say u need to LAMP.

susen
May 16 '07 #5

Motoma
Expert 2.5K+
P: 3,235
You can use mod_rewrite to modify URLs on the fly.
You can use a frame, as was previously suggested.
You can do something trickier, such as store the page in your $_SESSION variable, and immediately redirect to / which will automagically pick index.php which should then read the $_SESSION page and load the correct information.
May 16 '07 #6

Post your reply

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