473,800 Members | 2,526 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

how to hide file name (.php)

63 New Member
hi,
I see that it's easy to create a navigation like index.php?id=1, index.php?id=2. .. then you can hide the current part you are in. But I need a further step (as I've seen many), hope it's easy enough, that how can hide the file name index.php so that the above links become simple "?id=1, ?id=2... if so, that'd be great :)
Dec 26 '07 #1
14 3675
Markus
6,050 Recognized Expert Expert
Ok lets use
[php]
www.example.com/index.php?id=1
[/php]
for the demonstration url.

If you want to hide the 'index.php' name just cut it out

i.e:
[php]
www.example.com/?id=1
[/php]
Remeber to keep the forward slash - / - in there.

Note, this will only work for index pages as index pages are the default catch pages for browsers.

[php]
www.example.com/some_directory/index.php?id=1
//becomes
www.example.com/some_directory/?id=1
[/php]
So on and so forth.

Hope this helped :)
Dec 26 '07 #2
nathj
938 Recognized Expert Contributor
hi,
I see that it's easy to create a navigation like index.php?id=1, index.php?id=2. .. then you can hide the current part you are in. But I need a further step (as I've seen many), hope it's easy enough, that how can hide the file name index.php so that the above links become simple "?id=1, ?id=2... if so, that'd be great :)
Hi,

There is a realy neat and easy way to do this without loading loads and loads of directories that you don't wan't. The directories don't really hide where the visitor is they simply move it.

If you check out www.just10northeast.org.uk you will see the following outline in operation.

Every link calls a JavaScript function via the onclick method. This is instead of a normal href property.

The function takes a number of parameters, the first is the main control parameter which is used by the function to determine where the required page is defined. The second is anything the page definition requires and the third is the ID of a div on the main page.

Then using the first parameter the relevant page is determined and this is accessed using the XMLHTTP object with the secind paratmter in the query string which returns the definition and the JS function then writes this return to the div whose ID was supplied as the third parameter.

So this uses AJAX to solve the problem and it means that the URL is always the same and the site never reloads a full page but only part of it making it quite swift.

The key term for research here is AJAX.

If you want some more specific help then let me know and I'll happily look over any code for you and even help with a bit of development.

Cheers
nathj
Dec 26 '07 #3
helimeef
77 New Member
hi,
I see that it's easy to create a navigation like index.php?id=1, index.php?id=2. .. then you can hide the current part you are in. But I need a further step (as I've seen many), hope it's easy enough, that how can hide the file name index.php so that the above links become simple "?id=1, ?id=2... if so, that'd be great :)
Along with the first answer, you can also use a neat trick called mod_rewrite. It's a little bit advanced, but if you want to try it you can go to http://www.workingwith .me.uk/articles/scripting/mod_rewrite
And make sure that in httpd.conf (apache config file) AllowOverride is set to "All", so the line containing AllowOverride (without a # sign before it) should say "AllowOverr ide All".
Hope that helped.
Dec 26 '07 #4
tuananh87vn
63 New Member
thanks for all, you guys are so kind :)

if it's to work only then one of the above is enough of course, but I want to discover something new so the method involved AJAX would be great. if u don't mind, so tell me how?

again, thanks for your great help :D
Dec 27 '07 #5
realin
254 Contributor
why not try URL rewriting, if i understood your problem correctly.
Also you can edit .htaccess to hide the technology you write the files in. You can rename your file as index.pl and then some editing in .htaccess will treat .pl as .php , resulting files will compile as php files

If i misunderstood you then i am sorry

Cheers !!
Dec 27 '07 #6
nathj
938 Recognized Expert Contributor
thanks for all, you guys are so kind :)

if it's to work only then one of the above is enough of course, but I want to discover something new so the method involved AJAX would be great. if u don't mind, so tell me how?

again, thanks for your great help :D
Hi,

It's always good to learn something new so I've no porblem explaining the way I achieved this.

First of all you need a few JavaScript Functions.
Expand|Select|Wrap|Line Numbers
  1.  
  2. /*------------------------------------------------------------
  3.     GENERAL AJAX FUNCTIONS
  4. ------------------------------------------------------------*/    
  5. function writeResponse(poXMLHTTP, pcEmelentID) 
  6. {        
  7.     if (poXMLHTTP.readyState==4 || poXMLHTTP.readyState=="complete")
  8.     { 
  9.         if (poXMLHTTP.status == 200)
  10.         {
  11.             document.getElementById(pcEmelentID).innerHTML=poXMLHTTP.responseText ;  
  12.         }
  13.     } 
  14.  
  15. function GetXmlHttpObject()
  16.     if (window.XMLHttpRequest)
  17.     {
  18.         loXMLHTTP=new XMLHttpRequest() ;
  19.     }
  20.     else if (window.ActiveXObject)
  21.     {
  22.         loXMLHTTP=new ActiveXObject("Microsoft.XMLHTTP") ;
  23.     }     
  24.     if (loXMLHTTP==null)
  25.     {
  26.         alert ("Browser does not support HTTP Request")    ;
  27.          return    ;
  28.     }
  29.     return loXMLHTTP ;
  30.  
  31. function submitXMLHTTP(poXMLHTTP, pcIDToWriteTo, pcOpenMethod, pcURL, plOpen, pcSendData)
  32. {                                                                                        
  33.     poXMLHTTP.onreadystatechange = function() 
  34.     { 
  35.         // use of ghost function enables the system to execute each item in the correct order
  36.         writeResponse(poXMLHTTP, pcIDToWriteTo); 
  37.     };
  38.     poXMLHTTP.open(pcOpenMethod,pcURL,plOpen) ;
  39.     poXMLHTTP.send(pcSendData) ; 
  40.  
  41.  
  42.  
  43. /*------------------------------------------------------------
  44.     MENU/DISPLAY HANDLING FUNCTIONS
  45. ------------------------------------------------------------*/    
  46. function menuHandler(pnType, pnMenuID, pcWriteToID)
  47. {                                                  
  48.     if(trim(pcWriteToID) == "")
  49.     {
  50.         pcWriteToID = "mainContent" ; // default value
  51.     }
  52.  
  53.     // instantiate the XMLHTTP object
  54.     loXMLHTTP = GetXmlHttpObject() ;
  55.  
  56.     lcBaseURL = "pagedefinition/" ; // this is the directory where all the page definition files are stored
  57.  
  58.     // determine which URL we are loading to handle this menu selection
  59.     switch(pnType)
  60.     {
  61.         case 1: // Main content  
  62.             lcURL = lcBaseURL + "maincontent.php?page=" + pnMenuID ; // I then use the ID from the query string to select data out of a table. This may not be necessary if each page is static 
  63.             break ;
  64.         case 4: // downloads                   
  65.             lcURL = lcBaseURL + "download.php" ; // not all pages need this query string but the call to this function would still requie the middle parameter
  66.             break ;
  67.     } 
  68.     /* this is just a sample, I have about 9 different definitions in here. Most pages however use the first case as the page is fully definied in my database. As this is a switch statement you can add as many as you like*/
  69.  
  70.     submitXMLHTTP(loXMLHTTP, pcWriteToID, "GET", lcURL, true, null) ;
  71.  
Then in you html file - index.html you would have a section, I use <div> with the ID that is submitted as the third parameter, in my case this is mainContent

An example link would look like:
[html]
<a title="Link tool tip" onmousever="thi s.style.cursor= 'pointer';" onclick="menHan dler(1, 1, 'mainContent'); ">Link Text</a>
[/html]


The advantage of this system is that because the output section is a parameter you can use to retreive the definition of any section on your page. Also because the page definition file is located based on and paramter this is fully customisable. The middle parater can then be used to get an exact record from a database and so if you have a database you can use one file to define multiple pages by having the pages defined in the database.

Well there you have it. I've given away some code for you so I hope this will help you ti understand what is going on.

Have a play around with this and if you have any further questions just let me know.

Cheers
nathj
Dec 27 '07 #7
helimeef
77 New Member
why not try URL rewriting, if i understood your problem correctly.
Also you can edit .htaccess to hide the technology you write the files in. You can rename your file as index.pl and then some editing in .htaccess will treat .pl as .php , resulting files will compile as php files

If i misunderstood you then i am sorry

Cheers !!
I already said that, mod_rewrite.
Dec 27 '07 #8
tuananh87vn
63 New Member
hi,
I did have some tries and find mod_rewrite definitely useful, but I still wonders:

if the browser understands, say, www.site.com/page/download as www.site.com/index.php?id=5 so how can we still use the value $_GET['id']?, for which we have another purpose?

the second question, we change site.com/index.php?page= download into site.com/download, so how about site.com/index.php?page= download&action =get, for example?
Dec 28 '07 #9
Markus
6,050 Recognized Expert Expert
To answer your second question
using the same technique you used for mod_rewrite previously, make the url: www.site.com/download/action/get

Not sure about your first question

what are these 'other purposes' you spoke of?
Dec 28 '07 #10

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

Similar topics

6
5466
by: Els | last post by:
If I use <? include "file.html"; ?> in the html of my document, do I _have_ to change the extension of that document to .php, or would it still work and be valid if I let it remain .html? -- Els Mente humana é como pára-quedas; funciona melhor aberta.
4
13708
by: thehuby | last post by:
How do you get the name of the currently execting script? By this I mean the name of the include file that is being executed: File: include.php <?php //Call some function to display include.php or whatever my filename is ?> File: holder.php
18
2339
by: walterbyrd | last post by:
I am trying to develop an app where: the same file, in the same place, will be uploaded, and then processed. Everything I can find about uploading a file, uses a form that requires the user to either manually enter the path and file name, or to browse for the file. I do not want that. Ideally, I want the user to click on a link, and the server side php app does the rest. Again, the file always has the same name, and is in the same place....
6
1264
by: Olumide | last post by:
Hello - This has probably been asked before, but I would like to know when its best to name a file with either extension. Thanks, - Olumide
5
60702
kamill
by: kamill | last post by:
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
0
1398
by: aris1234 | last post by:
how to rename file name in DB..??? this my code, but this code only save image to folder, can't rename file in DB : <?php //Сheck that we have a file $folder = "../property/$spid"; if(!file_exists($folder))
1
1074
by: crazychrisy54 | last post by:
Hi there Using an XML file containing customer elements: <customers> <customer> <namebob </name> </customer> .... ... </customers>
4
2960
by: liberty1 | last post by:
Hi everyone. I appreciate your effort at helping newbies like me. I have the following problems and will appreciate urgent help. PROBLEM NUMBER 1: Using PHP and MySQL, I am able to upload picture successfully unto the server but not so with the file name of the picture even though other parameters in my form got inserted successfuly in the database. I have read several posts on this topic including here on this site but I can't get around...
12
3440
by: impin | last post by:
this is my upload.php <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>File Upload</title> </head> <?php
0
9695
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
1
10260
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10042
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9099
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7588
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6826
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5616
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4156
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3770
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.