Htaccess redirects URI to parent directory

I have a website hosted in /var/www/thesite(Apache server), this is a website Symfony2, so inside this folder I have a folder webthat my virtual host points to.

So my virtual host www.mysite.com -> /var/www/thesite/web

In this web folder, I have a .htaccessURL for convenient formatting.

Now I have added the API in /var/www/thesite/api, the API is implemented using Silex. I want to redirect the entire request http://www.mysite.com/apito this new structure.

So I added in /var/www/thesite/web/.htaccess

RewriteCond %{REQUEST_URI} ^/api
RewriteRule ^api(.*)$ ../api/web/index.php [NC,QSA,L]

But I get:

Invalid request

Your browser sent a request that this server could not understand.

I'm not sure if I can access the parent folder in .htaccess. I do not want to change my target virtualhost directory to avoid a security breach.

?

+4
1

, /var/www/thesite/web. , /var/www/thesite/ /var/www/thesite/api /var/www/thesite/web. 400 Bad ../api/ .

-, , php / api index.php:

RewriteRule ^api/(.*)$ /index_api.php [L]

index_api.php "../api/web/index.php".

+3

Source: https://habr.com/ru/post/1523463/


All Articles