Wordpress in a subfolder

Hi,

I have a setup where there are 2 installations of wordpress .One under /
and one under /wordpress . The configs are as below

##############################
location / {

try_files $uri $uri/ /index.php?q=$uri&$args;

}

location /wordpress {

try_files $uri $uri/ /wordpress/index.php?q=$uri&$args;

}

location ~ .php$ {
try_files $uri =404;
fastcgi_pass unix:/opt/pifpm/fpmsockets/picdn.sock;
fastcgi_index index.php;
include fastcgi_params;
}

######################

The problem is that URL’s like http://picdn.com/2013/01/hello-world/
work ;
but not http://picdn.com/wordpress/2013/01/04/hello-world/

The second URL simply redirects to http://picdn.com/2013/01/hello-world/

Here is what the nginx log show

122.164.61.17 - - [04/Jan/2013:08:14:22 -0500] “GET
/wordpress/2013/01/04/hello-world/ HTTP/1.1” 301 5 "
http://picdn.com/wordpress/" “Mozilla/5.0 (X11; Linux i686)
AppleWebKit/537.11 (KHTML, like Gecko) Chrome/23.0.1271.97
Safari/537.11”
122.164.61.17 - - [04/Jan/2013:08:14:22 -0500] “GET
/2013/01/hello-world/
HTTP/1.1” 200 3764 “http://picdn.com/wordpress/” “Mozilla/5.0 (X11;
Linux
i686) AppleWebKit/537.11 (KHTML, like Gecko) Chrome/23.0.1271.97
Safari/537.11”

Any idea why this might be happening?

Thanks in advance,

On Fri, Jan 4, 2013 at 8:16 PM, Anoop A. [email protected]
wrote:

           fastcgi_pass unix:/opt/pifpm/fpmsockets/picdn.sock;
           fastcgi_index index.php;
           include fastcgi_params;
    }

I think you forgot this line

fastcgi_param SCRIPT_FILENAME $request_filename;

On Fri, Jan 4, 2013 at 6:55 PM, Edho A. [email protected] wrote:

location / {

fastcgi_param SCRIPT_FILENAME $request_filename;


nginx mailing list
[email protected]
http://mailman.nginx.org/mailman/listinfo/nginx

In my fastcgi_params include file I have

==========
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
fastcgi_param REQUEST_URI $request_uri;

fastcgi_param DOCUMENT_ROOT $document_root;

fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

Will this not work?

Thanks

On Fri, Jan 4, 2013 at 8:29 PM, Anoop A. [email protected]
wrote:

fastcgi_param DOCUMENT_ROOT $document_root;

fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

Will this not work?

My last test few years ago showed $request_filename worked much
better. May or may not matter now, though. Still worth a try, I’d say.

On Fri, Jan 4, 2013 at 8:43 PM, Anoop A. [email protected]
wrote:

my wild guess says the $fastcgi_script_name doesn’t get passed
correctly (or in unexpected way, e.g. blank) when using try_files
causing it to use default /index.php.

On Fri, Jan 4, 2013 at 7:20 PM, Edho A. [email protected] wrote:

#fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

fastcgi_param SCRIPT_FILENAME $request_filename;

Actually i guess it was a caching issue with my browser when i was using
a
different try_files line

fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param SCRIPT_FILENAME $request_filename;

Both works now …

Thanks,

On Fri, Jan 4, 2013 at 7:05 PM, Edho A. [email protected] wrote:

My last test few years ago showed $request_filename worked much
better. May or may not matter now, though. Still worth a try, I’d say.


nginx mailing list
[email protected]
http://mailman.nginx.org/mailman/listinfo/nginx

Edho …that worked .Thanks

But curious to know whats the difference between

=====
#fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param SCRIPT_FILENAME $request_filename;

If I had set a

root /home/picdn/public_html/wordpress;

inside the location /wordpress …it would have worked ?.

Whats the best route to take here as I see many docs doing it
differently .

Thanks,

On Fri, Jan 4, 2013 at 9:12 PM, Anoop A. [email protected]
wrote:

fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param SCRIPT_FILENAME $request_filename;

Both works now …

Yeah, I don’t see difference with either setting. Though I’d say you
forgot to actually reload the config after adding the subdirectory
config since I also got redirect on the subdirectory url.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs