Welcome to WebmasterWorld Guest from 54.158.228.55

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

Trailing slash problem on PHP as CGI server

How to make trailing slash produce 404?

     
8:19 pm on Apr 2, 2012 (gmt 0)

WebmasterWorld Senior Member 5+ Year Member



This is an ongoing problem for me for which I've been posting in both Apache and PHP forums.
If the PHP is configured to run in Apache module, AcceptPathInfo Off directive resolves the problem.

But if the server has PHP configured to run as CGI or CGI/FastCGI module, this is a headache if I want to use PHP in any manner as I can't stop that trailing slash return content which creates endless number of links to endless number of duplicated pages.

Please, correct me if I'm wrong, but according to this, the directive should work, right:
[httpd.apache.org...]

Yet, adding AcceptPathInfo Off to .htaccess if the server is configured as CGI or CGI/FastCGI simply does not change anything.
I tried renaming HTML files to PHP so I don't need to use any AddHandler or AddType, but since PHP is being called, trailing slash returns content. Aaahhh...

For PHP folks that install and run PHP on their servers, what's up with this trailing slash when PHP is configured to run as CGI?
I learned about the background of it as PHP uses added stuff after the slash, fine. But how do I stop it?

Thanks

P.S.
I see I wrote "How to stop trailing slash produce 404?" in the sub-line of the subject. It should state "How to make trailing slash produce 404?"
9:11 am on Apr 3, 2012 (gmt 0)

WebmasterWorld Senior Member 5+ Year Member



In PHP CGI mode and apache 2 by default AcceptPathInfo is off unless the handler does something.

if you check $_SERVER['PATH_INFO'] what it returns? In my case is not set and I am running the php as cgi I don't get this problem you're saying.

Just in case some rules in your htaccess don't cause the problem you can try and setup an .htaccess with only the AcceptPathInfo
3:35 pm on Apr 3, 2012 (gmt 0)

WebmasterWorld Senior Member 5+ Year Member



Thanks very much for reply.

unless the handler does something

This happens only when PHP kicks in. Being that I use AddType or AddHandler in .htaccess, or if use pages with .PHP extensions.

I want to use PHP and parse HTML as PHP, but don;t want this slash cause duplicated content.
 

Featured Threads

Hot Threads This Week

Hot Threads This Month