Welcome! Log In Create A New Profile

Advanced

Custom SEO "Pretty URL's" problem with php-fpm 5.3.3+

Posted by Per Hansson 
Custom SEO "Pretty URL's" problem with php-fpm 5.3.3+
January 07, 2011 06:14AM
Hi, I've got a site with a vBulletin forum.
For our forum archive we have a custom solution where a PHP file with no extension is called to create some SEO friendly pretty URL's...

You can see it live here; http://www.techspot.com/vb/all
You will get redirected to a path ending in "windows" this is the PHP file...

This works fine in PHP v5.3.2 and lower
It also works fine in PHP v5.2.16

The rewrite I'm using in nginx looks like this;
[CODE]
## Forum Archive fastCGI pass
location /vb/all/ {
rewrite ^/vb/all/windows/(.*)$ /vb/all/windows?$1 break;
rewrite ^/vb/all /vb/all/windows/ permanent;
fastcgi_pass unix:/dev/shm/php.sock;
fastcgi_param SCRIPT_FILENAME $document_root/vb/all/windows;
fastcgi_param QUERY_STRING $query_string;
}
[/CODE]

Now I can't upload the file "windows" since it is not open source (vBulletin code)
But you can just create a small "HELLO WORLD" PHP file, or phpinfo file or similar and get the exact same behavior...
Example;

nginx code;
[CODE]
location /test/ {
fastcgi_pass unix:/dev/shm/php.sock;
fastcgi_param SCRIPT_FILENAME $document_root/test/tiger;
fastcgi_param QUERY_STRING $query_string;
}
[/CODE]

php file named "tiger";
[CODE]
<?php
echo 'Hello World!';
?>
[/CODE]

What I find is the last thing in the access log, we have a status code of "200" so everything is correct
However the byte size sent to the client is only 31 bytes, it should be 1740 bytes...
When I do "view source" in the client browser I see nothing, and the page itself is just a white page

It is as if error logging was not enabled, however there is nothing in the logs themselves, and the php.ini has all error reporting features I could find enabled

nginx debug log showing rewrites;
[CODE]
2011/01/07 12:10:34 [notice] 2783#0: *11 "^/vb/all/windows/(.*)$" matches "/vb/all/windows/", client: 192.168.0.1, server: 192.168.0.2, request: "GET /vb/all/windows/ HTTP/1.1", host: "192.168.0.2", referrer: "http://192.168.0.2/"
2011/01/07 12:10:34 [notice] 2783#0: *11 rewritten data: "/vb/all/windows", args: "", client: 192.168.0.1, server: 192.168.0.2, request: "GET /vb/all/windows/ HTTP/1.1", host: "192.168.0.2", referrer: "http://192.168.0.2/"
[/CODE]

nginx access log showing the file being processed (but only 31 bytes)
[CODE]
192.168.0.1 - - [07/Jan/2011:12:10:34 +0100] "GET /vb/all/windows/ HTTP/1.1" 200 31 "http://192.168.0.2/" "Mozilla/5.0 (Windows; U; Windows NT 5.2; en-US) AppleWebKit/534.16 (KHTML, like Gecko) Chrome/10.0.628.0 Safari/534.16" "-"
[/CODE]
Ruslan Sivak
Re: Custom SEO "Pretty URL's" problem with php-fpm 5.3.3+
January 08, 2011 02:36PM
On 1/7/2011 6:14 AM, Per Hansson wrote:
> What I find is the last thing in the access log, we have a status code
> of "200" so everything is correct
> However the byte size sent to the client is only 31 bytes, it should be
> 1740 bytes...
> When I do "view source" in the client browser I see nothing, and the
> page itself is just a white page
>
Have you looked at the php-fpm log? It should be in /var/log/php-fpm/

Russ
Re: Custom SEO "Pretty URL's" problem with php-fpm 5.3.3+
January 08, 2011 06:11PM
Hi Russ,
Yea, I tried running php-fpm with "debug" logging enabled but nothing is written in the logfile when I access this URL...

Per Hansson
Ruslan Sivak
Re: Custom SEO "Pretty URL's" problem with php-fpm 5.3.3+
January 08, 2011 06:50PM
I'm not really sure what's wrong, but are regular .php files working?
Is there a reason you can't just rename the windows file to windows.php
in that case?

Russ

On 1/8/2011 6:11 PM, Per Hansson wrote:
> Hi Russ,
> Yea, I tried running php-fpm with "debug" logging enabled but nothing is
> written in the logfile when I access this URL...
>
> Per Hansson
>
> Posted at Nginx Forum: http://forum.nginx.org/read.php?3,164296,164694#msg-164694
Re: Custom SEO "Pretty URL's" problem with php-fpm 5.3.3+
January 08, 2011 07:04PM
Hi Rus,
Yes, everything else on the site works great. All normal PHP files are processed by php-fpm just fine...

I prefer to keep our vBulletin archive this way so that old links to our website are not broken, of course I could rename the file on the filesystem to something else but I want the URL to remain unchanged.
I tried to get it working now like that (i.e. windows.php file on filesystem instead) but ran into the same issue, I'm not sure what causes it either :(

I've been looking for a changelog for php-fpm since it's working fine with php-fpm internal version number 0.6.0 on PHP v5.3.2 but breaks with php-fpm internal version number 0.6.5 on php v5.3.3 but so far have not been able to find much info about that either :(

Thank you
Per Hansson

Ruslan Sivak Wrote:
-------------------------------------------------------
> I'm not really sure what's wrong, but are regular
> .php files working?
> Is there a reason you can't just rename the
> windows file to windows.php
> in that case?
>
> Russ
Re: Custom SEO "Pretty URL's" problem with php-fpm 5.3.3+
January 30, 2011 04:17PM
I just realized that if I pass my extensionless PHP request to php-cgi instead of php-fpm it works fine in the latest version of PHP (v5.3.5)
I guess some check must have been added to php-fpm in versions >0.6.0 preventing it from processing a file with no file extension...?
In either case I've continued to look for a changelog for php-fpm or anything on this matter but found nothing, quite a bummer...
Re: Custom SEO "Pretty URL's" problem with php-fpm 5.3.3+
January 30, 2011 04:24PM
Why would you have an extensionless file on the filesystem? Seems
kinda funky to do it that way.

I'm wondering if you need to pass more fastcgi_params. I don't know.
Personally I'd rename the file to have a .php and just pass the
requests through the webserver using rewrites (you won't lose any
functionality.)

On Sun, Jan 30, 2011 at 1:17 PM, Per Hansson <nginx-forum@nginx.us> wrote:
> I just realized that if I pass my extensionless PHP request to php-cgi
> instead of php-fpm it works fine in the latest version of PHP (v5.3.5)
> I guess some check must have been added to php-fpm in versions >0.6.0
> preventing it from processing a file with no file extension...?
> In either case I've continued to look for a changelog for php-fpm or
> anything on this matter but found nothing, quite a bummer...
>
> Posted at Nginx Forum: http://forum.nginx.org/read.php?3,164296,170906#msg-170906
>
>
Re: Custom SEO "Pretty URL's" problem with php-fpm 5.3.3+
February 01, 2011 01:18PM
Thanks for the push in the right direction.
I moved the forum archive files into a subfolder named "windows" and renamed the extensionless file previously named "windows" to "index.php"

With this nginx conf it is now working fine on my testserver after setting up the correct new path to include files in the global.php file (this will be of use to any other users of vBulletin only)
[CODE]
Line 17; chdir('./..');
Change to; chdir('./../..');


## Forum Archive fastCGI pass
location = /vb/all/ {
rewrite ^ /vb/all/windows/ permanent;
}
location /vb/all/ {
fastcgi_pass unix:/dev/shm/php.sock;
fastcgi_param SCRIPT_FILENAME $document_root/vb/all/windows/index.php;
include fastcgi_params;
}
[/CODE]
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 171
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready