tags:

views:

38

answers:

2

Current versions of MediaWiki have the front page accessible via

http://www.example.com/wiki/index.php/Main_Page

Instead of the older version of

http://www.example.com/wiki/index.php?title=Main_Page

That second URL is literally how the PHP script would be called in most casual web apps, but the above URL is cleaner and more desirable. Now, I can see how that could easily be converted with an Apache mod_rewrite rule:

RewriteRule ^/index.php/(.*)$ /index.php?title=$1

But there's no htaccess file in the default MediaWiki setup. So how are they doing the redirect?

+3  A: 

Not sure if this is what they are doing, but there no need to redirect using a .htaccess. the page index.php is found and that script is what is loaded. index.php just gets $_SERVER['REQUEST_URI'] and parses that into the query string.

Jonathan Kuhn
+1 I'm fairly sure that, or the very near equivalent, is exactly what they're doing.
lonesomeday
I've done it in the past so I know it works. Just not feeling up to searching through mediawiki to find where they are doing it to confirm it.
Jonathan Kuhn
So, when apache gets a request for "/wiki/index.php/anything", it knows that "index.php" is the file because of the period? So if someone (unwisely) named a folder with a period in the middle, the contents of it would be unable to be served via apache, since it would always assume the folder was the target file, and the rest was the query string?
MidnightLightning
the period has nothing do to with it. As apache is traversing the requested url, it starts at the beginning (using your example of "/wiki/index.php/anything") and looks in the document root for a file/folder named "wiki", folder found so it continues on, looks for a file/folder named "index.php", file found so it stops and loads that file.
Jonathan Kuhn
A: 

hxxp://httpd.apache.org/docs/2.0/mod/core.html#acceptpathinfo

Zygmunt