0

I'm trying to set up nginx vhost so I can use wordpress and laravel on the same domain. I put wordpress in the root folder And in a subfolder /laravel/ installed laravel

Is it possible to make that if for example laravel route /laravel-page in URL, request on server will not go to wordpress /index.php but to Laravel /laravel/public/index.php, and all other pages are normally requested to /index.php I would like to whitelist URLs using RegExp, which will be handled by Laravel.

UPDATE: After a few experiments, I managed to get what I wanted. I added:

location ~ ^/laravel-page(?:/(.*))?$ {
    index /laravel/public/index.php;
}

These pages are now handled by Laravel: /laravel-page/1333/. But for some reason, if I enter the address without the slash /laravel-page/1333 , it gives a 404 error, and not from wordpress or laravel, but the usual one from nginx. I tried adding a redirect:

rewrite ^/(.*)/$ /$1 permanent;

It works, but laravel doesn't open.

Fox1q
  • 1
  • 1
  • Yeah, why shouldn't that be possible? Please share your attempts to resolve the problem – Nico Haase May 04 '21 at 10:52
  • After a few experiments, I managed to get what I wanted. I added: `location ~ ^/laravel-page(?:/(.*))?$ { index /laravel/public/index.php; }` These pages are now handled by Laravel: `/laravel-page/1333/`. But for some reason, if I enter the address without the slash `/laravel-page/1333` , it gives a 404 error, and not from wordpress or laravel, but the usual one from nginx. I tried adding a redirect: `rewrite ^/(.*)/$ /$1 permanent;` It works, but laravel doesn't open. – Fox1q May 04 '21 at 12:29
  • Please edit your question to contain all clarification - don't hide it in the comment section – Nico Haase May 04 '21 at 12:36

0 Answers0