www.site.com/?p=page instead of index.php?p=page

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
poverdrive
Forum Newbie
Posts: 3
Joined: Wed Aug 04, 2004 7:57 pm

www.site.com/?p=page instead of index.php?p=page

Post by poverdrive »

I've seen a number of sites that have their links like this:
http://www.site.com/?p=page .. normally I was intrigued & would now like to know how to do it too :)

I've always been doing links like somepage.php?var=value ..
If I try opening for example http://localhost/?p=some_test (for testing purposes obviously..) the browser outputs that anoying 403 error page.
Can anyone tell me how that shortening or masking or whatever is done?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

it has to do (often) with your documentindex settings..
LiquidPro
Forum Commoner
Posts: 37
Joined: Wed Aug 04, 2004 6:33 pm
Location: Akron, OH

Post by LiquidPro »

I believe if you have an index.php file it will automatically make it able to do that.
User avatar
nigma
DevNet Resident
Posts: 1094
Joined: Sat Jan 25, 2003 1:49 am

Post by nigma »

If you haven't configured index.php to be one of your directory indexes than it wont.
poverdrive
Forum Newbie
Posts: 3
Joined: Wed Aug 04, 2004 7:57 pm

Post by poverdrive »

If you haven't configured index.php to be one of your directory indexes than it wont.
Go on.. keep explaining :)
You see.. I've been kidding around with php for a little more than a month's time.. so I don't know that much. ;)
Or maybe I'm just confused.. what do u mean by configuring index.php as a directory index?
I'd appreciate some help here.. maybe even an example code if anyone could be bothered..?

Thx 4 your replies though.
LiquidPro
Forum Commoner
Posts: 37
Joined: Wed Aug 04, 2004 6:33 pm
Location: Akron, OH

Post by LiquidPro »

Make an .htaccess file in your directory, and put this in it...

Code: Select all

DirectoryIndex index.php
That should make it so that your index.php file will be called when the directory is accessed... hence allowing you to go... http://www.site.com/?action=whatever

Goodluck
User avatar
nigma
DevNet Resident
Posts: 1094
Joined: Sat Jan 25, 2003 1:49 am

Post by nigma »

If your using apache than the directory index is a directive inside the config file httpd.conf. Directives are basically what settings are called if you use apache. The directory index directive is a setting that tells apache which file(s) should be used by default.

When you use a url like http://www.domain.com/?p=page then you are trying to pass the variable p with the value "page" to the directory index, or the default page which could be blah.php or foo.php. Whereas if you use a url like http://www.domain.com/index.php?p=page than you are explicitly telling the webserver to open the page index.php and pass it the variable p with the value "page"

Here's apaches page on the directory index directive: http://httpd.apache.org/docs-2.0/mod/mo ... ctoryindex

Sorry if that wasn't clear, please tell me if you don't understand.
poverdrive
Forum Newbie
Posts: 3
Joined: Wed Aug 04, 2004 7:57 pm

Post by poverdrive »

that did the trick :)
thx a lot LiquidPro for the code & nigma - thx for explaining the whole thing :)
gee I never expected so many replies in such a short time ;)
User avatar
nigma
DevNet Resident
Posts: 1094
Joined: Sat Jan 25, 2003 1:49 am

Post by nigma »

I've got no life for the next few days so i'll be hanging around here and posting quite a bit.
LiquidPro
Forum Commoner
Posts: 37
Joined: Wed Aug 04, 2004 6:33 pm
Location: Akron, OH

Post by LiquidPro »

Same here :)
d3ad1ysp0rk
Forum Donator
Posts: 1661
Joined: Mon Oct 20, 2003 8:31 pm
Location: Maine, USA

Post by d3ad1ysp0rk »

Next few days.. loser. Try the next few years. ;)
User avatar
nigma
DevNet Resident
Posts: 1094
Joined: Sat Jan 25, 2003 1:49 am

Post by nigma »

welcome aboard liquidpro. hope you enjoy the forums
LiquidPro
Forum Commoner
Posts: 37
Joined: Wed Aug 04, 2004 6:33 pm
Location: Akron, OH

Post by LiquidPro »

Haha, thanks... I appreciate it.

So far, they're great. I'm surprised by the amount of activity on them.
Post Reply