Jump to content

PHP URI parsing


peeper

Recommended Posts

Hi,

 

Say I have a web application called web-app running on server and it contains an index.php file in the application's root directory. Can anyone explain why PHP passes a URI of the following form

http://server/web-app/index.php/extrastuff

to the index.php file under the application's root, rather than an index file under the (non-existent) /index.php/extrastuff/ directory?

 

I've looked in the PHP documentation and can't find any PHP URI processing rules that deals with this type of URI. Can anyone point me to resources that explain PHP URI processing behaviour dealing with this stuff, please?

 

Thanks,

 

Peeper.

 

Link to comment
https://forums.phpfreaks.com/topic/49197-php-uri-parsing/
Share on other sites

http://www.sitepoint.com/article/search-engine-friendly-urls

 

More or less for search engine friendly, but maybe this will help.

 

I think PHP checks if there is a file present, so let's say I had a a directory called index.php, so my url looks like this:

 

www.mysite.com/index.php/index.php

 

Well if mysite.com has a file in the root directory called index.php that would trump the directory naming convention and php will read that file and add /extrastuff to the query string.

 

If there is no file called index.php but there is a directory than it will look inside that directory.

 

Basically what is happening is index.php shows as a file and anything after that is considered to be part of the query string. It is very nice for search engine optimization.

 

I have never made a directory called index.php so the trumping could be wrong. The best way to find out is to test it yourself.

Link to comment
https://forums.phpfreaks.com/topic/49197-php-uri-parsing/#findComment-241077
Share on other sites

Thanks for that, frost110. The article on search engine-friendly URIs is interesting and goes some way to explain the URI processing rules of Apache + PHP. I have tried a variety of "search engine-friendly" URIs to see how they are processed. However, to ensure I don't miss any tricks, I would really like to see a canonical definition of the rules that PHP (and/or Apache) applies to URIs of the form we're talking about here.

 

Any suggestions or references?

 

Thanks,

 

Peeper.

 

Link to comment
https://forums.phpfreaks.com/topic/49197-php-uri-parsing/#findComment-241089
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.