954,228 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Simple (I think) Code Question

Can anyone tell me how I would code links to other pages on my site (using php) whereby the full URL in the address bar looks like this:

http://www.mysite.com/index.php?id=3 (which points to blah.php)

I've done the usual searches on google and such with no luck on how to do it.

Mind you, I'm *not* a coder/webmaster so if you start talking about arrays and such, I'll have no idea what you're talking about :)

TheOgre
Posting Whiz
393 posts since Aug 2003
Reputation Points: 128
Solved Threads: 9
 

I assume you want to redirect from http://www.mysite.com/index.php?id=3 to http://www.anothersite.com/blah.php

You can use header() function to do it.

If not, post here again. :)

PoA
Posting Whiz in Training
237 posts since Jul 2004
Reputation Points: 26
Solved Threads: 9
 

No, what I want to do is hide the actual page link, so the URL reads:

http://www.mysite.com/index.php?id=2

instead of:

http://www.mysite.com/iwanttohidethispage.html

No redirection to another domain, just hiding the actual pages from showing up in the location bar of the browser. For an example, please see http://www.cacert.org

TheOgre
Posting Whiz
393 posts since Aug 2003
Reputation Points: 128
Solved Threads: 9
 

Well, it's mod_rewrite. You can check out at http://www.mod-rewrite.com/forum/thread10.html

PoA
Posting Whiz in Training
237 posts since Jul 2004
Reputation Points: 26
Solved Threads: 9
 

hmm. sounds to me like a simple include, but that's probably inefficient.

[PHP]
<?php

$pages = "/path/to/pages/";
$default = 1;

if(is_file($pages.$_GET['id'].".php")) $p = $_GET['id'];
else $p = $default;

include $pages.$p.".php";
?>
[/PHP]

Just have all your pages as ID numbers.. IE: news page = 3.html

But that's really inefficient, and probably not how you do it =P

kenleycapps
Newbie Poster
9 posts since Aug 2004
Reputation Points: 10
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You