0

I am wondering what special meaning does text in the URL have after index.php/ So I would have an address like www.site.com/index.php/sometext Is it parsed as a GET parameter, or something else.

I am working on a PHP framework for my personal use. The problem I'm trying to solve is URL routing.

5
  • stackoverflow.com/questions/2839666/php-clean-url Commented Feb 27, 2013 at 16:53
  • Thanks, but that doesn't answer my question about the URL parsing. Commented Feb 27, 2013 at 16:54
  • 1
    @Rasteril It does in one of the answers. See httpd.apache.org/docs/2.2/mod/core.html#acceptpathinfo Commented Feb 27, 2013 at 16:54
  • What's the framework? Most frameworks do routing for you. Commented Feb 27, 2013 at 16:54
  • @JasonMcCreary I am building my own mini framework, I kinda wanted to know the behind the scenes action. Commented Feb 27, 2013 at 16:57

3 Answers 3

2

I am wondering what special meaning does text in the URL have after index.php/

There is no intrinsic special meaning there. Special meaning gets assigned after the first ? and after the first #.

That said, the same script will be run for /index.php and /index.php/foo/bar/baz, and the full URL requested will be available via $_SERVER, so the script can add its own special meaning to it.

See $_SERVER['REQUEST_URI'] and $_SERVER['PATH_INFO'] for some interesting bits. print_r on $_SERVER is also worthwhile.

Sign up to request clarification or add additional context in comments.

1 Comment

Is there any way to see what the user has typed into the space, even though it has no meaning at first?
1

Most frameworks use the text after index.php to route the request without having to rely on ugly query (ex: ?page=foo). So removing the index.php with some .htaccess rule for instance would provide a way to have beautiful urls: site.com/foo/bar. The part after the index.php can be accessed via $_SERVER['PATH_INFO'].

Comments

1

Path after /index.php is available inside your index.php code as:

 $_SERVER["PATH_INFO"] 

e.g. for the URL of http://domain.com/index.php/nice/url:

$_SERVER["PATH_INFO"]=/nice/url 

This technique is used to create clean/pretty URL in PHP without any support of .htaccess.

2 Comments

So what is generally preferred: htaccess, or this method?
.htaccess is preferred way of geting pretty URL actually.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.