I'm trying to host a nuxt symfony project, and I'm kind of stuck here.
I suppose what I need is some .htaccess rewriting.
I have 2 separate folders :
/
- /backend, which is basically my symfony folder.
- /frontend, containing my nuxt app.
I would need to redirect all of the requests that do not contain "/api"
to the /frontend
folder, and all requests containing "/api"
to "/backend/"
.
Example :
mydomain.com/articles/5
would redirect to mydomain.com/frontend/articles/5
mydomain.com/api/article/5
would redirect to mydomain.com/backend/article/5
Any help would be really useful,
thank you.
CodePudding user response:
Assuming you have additional .htaccess
files in the /frontend
and /backend
subdirectories that also use mod_rewrite to route the URL then you could do something like the following in the root .htaccess
file:
RewriteEngine On
# Rewrite "/api/<something>` to backend
RewriteRule ^api/(.*) backend/$1 [L]
# Everything else rewritten to frontend
RewriteRule (.*) frontend/$1 [L]