Web Development

General discussion


Virtual Pages / Scripts as Directories

By techsup ·
I recently began supporting a new site that uses virtual pages - or more appropriately - php scripts in the directory structure. When trying to convert the site to another server these pages/scripts do not work.
A mammals file exists at http://www.myserver.com/animals/
with the following code:

require_once($_SERVER['DOCUMENT_ROOT'] . '/_includes/config.php');
list($a, $cat_id) = explode("/", $_SERVER['PATH_INFO']);
if($cat_id=='' || !is_numeric($cat_id)){
echo "Invalid or no parameter supplied";
echo "Invalid category supplied";

Does a redirect or dns alias need to be setup for the mammals file to work properly? Is this an "approved" method of displaying virtual pages?

This conversation is currently closed to new comments.

Thread display: Collapse - | Expand +

All Comments

Collapse -

by techsup In reply to Virtual Pages / Scripts a ...

The url would actually be .../mammals/72
which would display the Dog Category.

The script continues after to retrieve the data from the Database and display the webpage.
However, I can only get it to work when I have .../mammals.php/72 in the url instead of just .../mammals/72

Thanks for the help.

Collapse -

by Jaqui In reply to Virtual Pages / Scripts a ...

is the server set to allow the url aliasing?

and shouldn't it be $DOCUMENT_ROOT?

but the $_SERVER and the doc root shouldn't need to be specified.
you should be able to get the include with:


require_once "/includes/config.php"

the _ in the path may also cause an issue, depending on server config.

Collapse -

by techsup In reply to

After further research, this is just an alternate method of processing Search Engine friendly URL's(url aliasing). You are correct on Document_Root as well.

Collapse -

by techsup In reply to Virtual Pages / Scripts a ...

This question was closed by the author

Related Discussions

Related Forums