Forum Moderators: coopster

Message Too Old, No Replies

Ways to trigger PHP.INI

         

smallcompany

6:51 pm on Apr 18, 2012 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



My site is static HTML.

I have a PHP script that grabs data from referring URL which is then written into a cookie.
The script is called by using auto_prepend_file command from PHP.INI.
In order for PHP.INI to be called, I have to parse HTML as PHP by using AddHandler directive in .htaccess.

The problem is that in the scenario where shared hosting has PHP setup as CGI, I cannot turn off the trailing slash option or however is that called.
Normally I would use AcceptPathInfo Off directive which so far worked only on the shared servers where PHP is setup as Apache, while it would have no effect on those setup as CGI.

Two hosting companies (PHP as CGI) replied that they disabled AcceptPathInfo on a server level. I don't know much about this so I have no clue if this is true or they're just trying to gate me off their backs.

Now I wonder about ideas on how to trigger PHP.INI while not parsing HTML file as PHP - in other words - not to use AddHandler or AddType directives.
Would that be possible?

Thanks

incrediBILL

9:47 am on Apr 19, 2012 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Why are you trying to avoid AddHandler or AddType, obvious and simple solutions?

smallcompany

3:15 pm on Apr 19, 2012 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Why are you trying to avoid AddHandler or AddType

It enables the trailing slash return 200. And I'm not referring to trailing slash in paths like this:

example.com/folder/ vs. example.com/folder

I'm referring to this:

example.com/page.html/

The above URL is wrong and yet it returns 200 (content of page.html) which is technically another page with same content. As it goes indefinitely, it creates thousands of pages as soon as Google pick just one like this.

I can implement a redirect to strip the trailing slash, but cannot believe this setting cannot be turned off on PHP as CGI servers like it can on those configured as Apache.

incrediBILL

5:09 pm on Apr 19, 2012 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Another field you could test for trailing slash is the REQUEST_URI, is this field being filtered as well?

smallcompany

6:01 pm on Apr 19, 2012 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Another field you could test for trailing slash is the REQUEST_URI, is this field being filtered as well?

Sorry, but I don't get this. I just checked on REQUEST_URI and found not much reference at php.net:
The URI which was given in order to access this page; for instance, '/index.html'.


So far my best bet was to 301 rewrite such requests (remove slash and everything that comes after it).
Another thing I may do is simply move all of my sites from PHP as CGI hosts to those that have PHP configured as Apache (so AcceptPathInfo works). So far I have two and I probably want two more. That may be the simplest solution.

My biggest disappointment is that so far, after hours spent on search, numerous posts here, I'm still to learn exactly why AcceptPathInfo gets ignored on servers that have PHP configured as CGI. Hosts explained like they disabled AcceptPathInfo on a server level, but why then this works on shared hosting where PHP is configured as Apache? Heck. Those first guys said something like security issues, but I know that the other two that run it as Apache are reputable and well known in hosting community so they would surely disable it if it was really a risk.

Thanks