What file is being accessed if there is a /? after the website address?

280 Views Asked by At

This may sound like a stupid question, but I have to know the answer. I have seen many sites that use URLs like the following: http://www.example.com/?p=1

What file is being accessed? I have always used something like http://www.example.com/somepage.php?p=1. When the "?" is there by itself, what does that mean?

I have recently installed phpList to handle my email campaigns, and the program uses this type of URL for the subscribe page. I cannot figure out what page it is accessing though. To see it in action you can go to https://www.mylittleblackebook.com/lists/?p=subscribe&id=3.

Thank you in advance for any light you can shed on this.

3

There are 3 best solutions below

4
On BEST ANSWER

It depends of the web server that you use. If you are on Apache, the DirectoryIndex property is what you are looking for.

Here is its default value :

DirectoryIndex index.html index.htm default.htm index.php index.php3 index.phtml index.php5 index.shtml mwindex.phtml

By default (IE. no page specifically called, as in your example), Apache will search every file listed above in the specified order, and use the first one found.

Parameters are handled the same way with a file name specified or not. The default file used will be able to read them.

1
On

By default you are accessing index.*. So www.example.com is same as www.example.com/index.php.

To pass any arguments, you use ? for first argument and & for any other argument. Like www.emaple.com/index.php?p=1&r[0]=2&r[1]=5. Since you can omit index.* you can write www.example.com/?p=1&r[0]=2&r[1]=5.

So www.example.com/?p=1 is accessing index.* file (most likely it's index.php).

1
On

Read this for further information (about ?p1=v1&p2=v2 in url):

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

Examples:

http://www.example.com/?p=1

means in server side:

print_r($_GET); //Array( p => 1)

https://www.mylittleblackebook.com/lists/?p=subscribe&id=3.

means in server side:

print_r($_GET); //Array( p => subscribe, id => 3)

What file will you get according to that parameters? Those parameters does not matter if there is no php redirection according to any $_GET value.

Read the .htaccess file first to figure out the server redirection. If there is no such file, this is the rule:

  • www.site.com --> index.php
  • www.site.com/page -> page.php
  • www.site.com/dir/page -> /dir/page.php

Note that any php file can contain redirection, it can be done using meta html tag and even using JavaScript.

When the "?" is there by itself, what does that mean?

It has no additional meaning. (It can be detected in $_SERVER['REQUEST_URI'] if you want)