Wordpress Multi-Site Converting Apache to Nginx

Francis Daly francis at daoine.org
Tue Apr 29 22:41:34 UTC 2014


On Tue, Apr 29, 2014 at 04:27:36PM -0400, nrahl wrote:

Hi there,

> Some of the links want to go to a URL like /wp-admin/network/ and it should
> silently redirect to /wordpress/wp-admin/network/. That's what the first
> apache rule does. I've tried to create an Nginx rule:
> 
> location ^~ ^/(wp-(content|admin|includes).*) {
>    try_files /wordpress/$1 =404;
> }
> 
> But I get a 404. So its matching the pattern but not loading the redirected
> content.

That's not what is happening. "location ^~" is a prefix match, not a
regex match, so this location is probably not being used by anything.

> I also have some pattern matching functions that insist on matching URLs
> they aren't supposed to. The ^~ is supposed to make the rule a higher
> priority, but it does not work.

That's not what ^~ means.

> These are all the location blocks I have on the server:
> 
>    index Director.php index.php;
> 
>    location ^~ ^/(wp-(content|admin|includes).*) {

That probably won't match any request.

>    location ^~ ^/blog/([a-zA-Z0-9\-\_]+)/ {

That probably won't match any request.

>    # Attempt to match Slugs for Director
>    location ~ ^/([a-zA-Z0-9\-\_]+)/$ {

That should match requests of the form /XXX/.

>    location ~ ^/([a-zA-Z0-9\-\_]+)/([a-zA-Z0-9\-\_]+)/$ {

That should match requests of the form /XXX/YYY/.

>    location / {

That should match any request that does not otherwise match a location.

>    # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
>    location ~ \.php$ {

That should match a request of the form /XXX.php.

> What am I doing wrong?

Misunderstanding what "location" does?

http://nginx.org/r/location

What request do you make?

Which one of the above locations does the request match?

What output do you expect?

What output do you get?

(And what do the logs say?)

	f
-- 
Francis Daly        francis at daoine.org



More information about the nginx mailing list