homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Visit PubCon.com
Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

Trailing slash problem on PHP as CGI server
How to make trailing slash produce 404?

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

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:

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?


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)

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)

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.

Global Options:
 top home search open messages active posts  

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved