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 :)
14 3621
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 :)
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
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 "AllowOverride All".
Hope that helped.
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
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 !!
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. -
-
/*------------------------------------------------------------
-
GENERAL AJAX FUNCTIONS
-
------------------------------------------------------------*/
-
function writeResponse(poXMLHTTP, pcEmelentID)
-
{
-
if (poXMLHTTP.readyState==4 || poXMLHTTP.readyState=="complete")
-
{
-
if (poXMLHTTP.status == 200)
-
{
-
document.getElementById(pcEmelentID).innerHTML=poXMLHTTP.responseText ;
-
}
-
}
-
}
-
-
function GetXmlHttpObject()
-
{
-
if (window.XMLHttpRequest)
-
{
-
loXMLHTTP=new XMLHttpRequest() ;
-
}
-
else if (window.ActiveXObject)
-
{
-
loXMLHTTP=new ActiveXObject("Microsoft.XMLHTTP") ;
-
}
-
if (loXMLHTTP==null)
-
{
-
alert ("Browser does not support HTTP Request") ;
-
return ;
-
}
-
return loXMLHTTP ;
-
}
-
-
function submitXMLHTTP(poXMLHTTP, pcIDToWriteTo, pcOpenMethod, pcURL, plOpen, pcSendData)
-
{
-
poXMLHTTP.onreadystatechange = function()
-
{
-
// use of ghost function enables the system to execute each item in the correct order
-
writeResponse(poXMLHTTP, pcIDToWriteTo);
-
};
-
poXMLHTTP.open(pcOpenMethod,pcURL,plOpen) ;
-
poXMLHTTP.send(pcSendData) ;
-
}
-
-
-
-
/*------------------------------------------------------------
-
MENU/DISPLAY HANDLING FUNCTIONS
-
------------------------------------------------------------*/
-
function menuHandler(pnType, pnMenuID, pcWriteToID)
-
{
-
if(trim(pcWriteToID) == "")
-
{
-
pcWriteToID = "mainContent" ; // default value
-
}
-
-
// instantiate the XMLHTTP object
-
loXMLHTTP = GetXmlHttpObject() ;
-
-
lcBaseURL = "pagedefinition/" ; // this is the directory where all the page definition files are stored
-
-
// determine which URL we are loading to handle this menu selection
-
switch(pnType)
-
{
-
case 1: // Main content
-
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
-
break ;
-
case 4: // downloads
-
lcURL = lcBaseURL + "download.php" ; // not all pages need this query string but the call to this function would still requie the middle parameter
-
break ;
-
}
-
/* 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*/
-
-
submitXMLHTTP(loXMLHTTP, pcWriteToID, "GET", lcURL, true, null) ;
-
}
-
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="this.style.cursor='pointer';" onclick="menHandler(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
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.
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?
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?
Hi, if you are looking for something like this where the id is dynamically generated at runtime:
site.com/page/download/action/get/id/4875
which would translate to:
site.com/index.php?page=download&action=get&id=4875
To do this try something like this in your htaccess: -
RewriteEngine on
-
RewriteRule ^page/download/action/get/id/(.*) index.php?page=download&action=get&id=$1
-
Then in your php script that generates the link just do something like: -
<a href="page/download/action/get/id/<?= $some_id ?>">Download</a>
-
From here you can simply access the url segments from the $_GET array -
<?= $_GET['action'] ?> or <?= $_GET['id'] ?>
-
One last thing. If you need totally dynamic urls just write a rule to point everthing but images, js files, css etc to index.php and then you can split the url on the forward slash and access the segments that way.
I hope that helps you out
RewriteEngine on
RewriteRule ^page/download/action/get/id/(.*) index.php?page=download&action=get&id=$1
[/code]
I believe, if you wanted the url's appearence to stay the same, you'd have to add [L] to the end of the Rule
i.e. -
RewriteEngine on
-
RewriteRule ^page/download/action/get/id/(.*)
-
index.php?page=download&action=get&id=$1 [L]
-
:)
I believe, if you wanted the url's appearence to stay the same, you'd have to add [L] to the end of the Rule
i.e. -
RewriteEngine on
-
RewriteRule ^page/download/action/get/id/(.*)
-
index.php?page=download&action=get&id=$1 [L]
-
:)
That is just to let apache know that it is the last rule. The code works fine. I may be missing something, could you explain what you mean by "if you wanted the url's appearence to stay the same".
Thanks
To keep the url from changing from www.site.com/action/get/id/3223 to www.site.com/?action=get&id=3223
The best example is myspace
www.myspace.com/user_name this is how the url looks but essentially its www.myspace.com/?user=user_name
Sorry.. im tired. hha. :)
To keep the url from changing from www.site.com/action/get/id/3223 to www.site.com/?action=get&id=3223
The best example is myspace
www.myspace.com/user_name this is how the url looks but essentially its www.myspace.com/?user=user_name
Sorry.. im tired. hha. :)
Thanks markusn00b, I'm not an expert with mod rewrite :)
Sign in to post your reply or Sign up for a free account.
Similar topics
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?
--...
|
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...
|
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...
|
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
|
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...
|
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";...
|
by: crazychrisy54 |
last post by:
Hi there
Using an XML file containing customer elements:
<customers>
<customer>
<namebob </name>
</customer>
....
...
</customers>
|
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...
|
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">...
|
by: DolphinDB |
last post by:
Tired of spending countless mintues downsampling your data? Look no further!
In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: Vimpel783 |
last post by:
Hello!
Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
|
by: jfyes |
last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
|
by: ArrayDB |
last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
|
by: PapaRatzi |
last post by:
Hello,
I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
|
by: Defcon1945 |
last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
|
by: af34tf |
last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
| |