0

I have a laravel server fronting a wordpress hosted on another server. The laravel server is receiving all traffic. I would like to direct specific routes to the local index.php (laravel) and all others to the wordpress. Like this:

/a/* --> laravel server (localhost) /b/* --> laravel server (localhost) /* --> wordpress (separate server) 

My nginx conf currently has this:

index index.html index.htm index.php; location ~* /[a|b]/.+ { try_files $uri $uri/ /index.php?$query_string; } location ^~ / { proxy_pass https://10.0.1.44; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; } 

The wordpress is receiving all routes. How can I force /a/* and /b/* to get served by index.php on the local server?

1 Answer 1

2

The problem is location ^~ / directive. This makes the prefix match explicit and prevents nginx from looking at regular expression matches.

Try the following:

location ~*^/[ab] { try_files $uri $uri/ /index.php?$query_string; } location / { proxy_pass https://10.0.1.44; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; } 

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.