Jump to content

[SOLVED] PHP paths as variable arguments?? (like wikipedia?)


Recommended Posts

how is that done?  is it some server variable they're interpreting?? if so, what "page" is it that you can use to write custom code to evaluate that variable?? do you have to change your default web server error pages to look for that?  please help me out with a general direction on how something like:

 

http://en.wikipedia.org/wiki/Operation_Northwoods

 

...i'm guessing it's not that they individuall create some crazy folder structure on the web server...  any help would be greatly appreciated.

umm, not sure what you are getting at, but I'll take a shot in the dark.

create a folder called "pages". Create a file called Default.html and write some html in it like:

<h2>Welcome</h2>

create a file called "hello.html" and write some html in it like:

Good Job<b>!!!</b>

In the page you want people to go to where they will be calling these files, do something like this:

<?php
$page = "Default";
if(isset($_GET['Page']) && is_file("pages/".$_GET['Page'].".html")){ //CHECK THAT THE FILE EXISTS
    $page = $_GET['Page'];
}
include("pages/".$page.".html");
?>
then link to those page like <a href="index.php?Page=hello">Hello page</a>

try that if that is anything like what you are looking for

no i understand how to pass varirable arguments with PHP.  My question is... like wikipedia with doesn't use the somepage.php?url=blah&something=something_else -- their arguments look specifically a folder structure.  my question is, if they are not actually created a folder structure for every one of their arguments, how do i intercept the incoming request to the webserver that would look like it was trying to read the default or index file off of the folder structure?

 

just like wikipedia...

ooohh, sorry. That is called URL Rewritting. That is a server function of some sort. Apache does it very easliy supposidly but most other servers also have the ability to do so. Wish I could give you some more info, but never worked with it personally.

For anyone who's looking into this and has a hosting service where they can only modify the .htaccess file, here is a very good reference taht explains every aspect of what I was looking for -- thanks for the direction Brian.

 

http://roshanbh.com.np/2008/03/url-rewriting-examples-htaccess.html

 

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.