0

I am having what I believe is a strange problem. I have several sites developed on the same hosting platform. All site seem to be fine except for one of them. The website is set up around 1 page (index.php) that retrieves the correct data to display from the database based on the path_info - this has worked for years - now on one site this has stopped working. By stopped working I mean it the page below now goes to a 404 error - I was under the impress that it should see the index.php as the script to use.

I believe this is an issue with htconfig or another file I don't have access to being misconfigured on the host's end. Perhaps someone can shed light on where I might direct them. My own htaccess file is completely empty:

wwww.testsite.com/index.php/page1

The above used to go to index.php and then using $_SERVER path_info retrieve page1 and get the contents associated with page1 from the database and display that on the page. Can someone confirm I am not going mad - that the above should go to index.php please? and perhaps too explain why the url is now seen as non-existent since it doesn't seem to be going to index.php but to page1. Thanks in advance for any advice.

kaliok
  • 11
  • 4

2 Answers2

1

Can someone confirm I am not going mad - that the above [wwww.testsite.com/index.php/page1] should go to index.php please?

Nope. That should look for a file called page1 in the directory index.php in the document root for www.testsite.com.

I think you used to have an .htaccess file that looked something like this:

RewriteEngine on
RewriteRule ^index.php(.*)$ index.php

Another possibility is that MultiViews were previously enabled and now not anymore. With MultiViews you also get the behavior you described. If it's allowed by the hoster, you can enable it by simply creating an .htaccess file containing:

Options MultiViews

If you put an .htaccess file with either one of abovementioned solutions in it in your document root, you can verify this.

CodeCaster
  • 147,647
  • 23
  • 218
  • 272
  • thanks codecaster. I am going to add the rewrite code in and test it - but just for peace of mind can you tell me a bit more above multi views - i looked at the page link you supplied but is this something that is done in the htconfig file? – kaliok Nov 02 '11 at 12:59
  • From that link: "MultiViews is a per-directory option, meaning it can be set with an Options directive within a , or section in httpd.conf, or (if AllowOverride is properly set) in .htaccess files." – CodeCaster Nov 02 '11 at 13:01
  • putting in options multiviews gave me a Internal Server Error :( – kaliok Nov 02 '11 at 13:02
  • and the rewrite rule doesn't seem to fix the issue either :( – kaliok Nov 02 '11 at 13:04
  • Please show you're willing to find a solution too, and don't expect me (or whoever) to Google for you. "options multiviews internal server error" gave me [this](http://mathiasbynens.be/notes/apache-allowoverride-all) site. Long story short, your hoster should enable it. Or you could try the mod_rewrite part. – CodeCaster Nov 02 '11 at 13:04
  • No problem, but what happens with the rewrite rule? And can you access Apache's error logs? – CodeCaster Nov 02 '11 at 13:12
  • rewrite rule still not working... Not being picked up in the error log as an error. I spoke to the hosting provider who confirmed that I wouldn't have access to the options multiviews but while they are investigating in the meantime I wanted to see if I could fix the issue with the rewrite rule (which I can use - as I have used them before on other sites). Have switched it to test.php and adjusted the rule accordingly - still not being see :( – kaliok Nov 02 '11 at 13:22
  • Have now tried the rewrite rule on another site on the same host. Worked fine - my conclusion is that something has gone amiss with the host's htconfig file. Thanks again, codecaster, for your help. – kaliok Nov 02 '11 at 17:21
0

In Apache, if you have AcceptPathInfo on anywhere relevant in the Apache config (including in .htaccess, if the server config allows it) and there's a file /index.php, then /index.php/stuff should indeed go to /index.php, and should set $_SERVER['PATH_INFO'] to "/stuff". The CGI script handler and mod_php* even do this by default, so it should just work unless it's explicitly turned off.

Either way, if it's currently off, you can turn it back on by adding AcceptPathInfo on to your .htaccess file, if AllowOverride FileInfo is set for the site.

I make no promises about other web servers, but PATH_INFO is part of the CGI spec, so i'd think most servers would have a similar setting.

cHao
  • 84,970
  • 20
  • 145
  • 172
  • A possible way to configure your nginx to work this way is written in here: http://stackoverflow.com/questions/8265941/empty-value-to-path-info-in-nginx-returns-junk-value – SimonSimCity Feb 17 '12 at 08:47