Htaccess - install symfony2 in a subfolder

I am trying to deploy a symfony application to a subfolder of my root directory and I am trying to figure out how to do this correctly. I will just explain the situation. In my root directory there is a subfolder named /private that contains the htaccess file, which is redirected to /private/web/current/ (I am deploying using capistrano).

Folder structure

 - ROOT/ ---- private/ ------- .htaccess (1) ------- current/ ----------- web/ ------------- app.php ------------- .htaccess (2) 

htaccess (1)

 RewriteEngine On RewriteRule ^$ /private/current/web/ [L] 

htaccess (2)

 DirectoryIndex app.php <IfModule mod_rewrite.c> RewriteEngine On RewriteCond %{REQUEST_URI}::$1 ^(/.+)/(.*)::\2$ RewriteRule ^(.*) - [E=BASE:%1] RewriteCond %{HTTP:Authorization} . RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}] RewriteCond %{ENV:REDIRECT_STATUS} ^$ RewriteRule ^app\.php(/(.*)|$) %{ENV:BASE}/$2 [R=301,L] RewriteCond %{REQUEST_FILENAME} -f RewriteRule .? - [L] RewriteRule .? %{ENV:BASE}/app.php [L] </IfModule> <IfModule !mod_rewrite.c> <IfModule mod_alias.c> RedirectMatch 302 ^/$ /app.php/ </IfModule> </IfModule> 

Result

When I request /private , I get Symfony error :

 No route found for "GET /private/" 

When I request /private/login AND /login , I get a browser error :

 Not Found The requested URL /private/login was not found on this server. 

Symfony now performs routing from the root directory, but the root for the symfony project is actually / private. I am a noob in deployment and htaccess rules, so is there anyone who can help me?

early.

+5
source share
1 answer

I think the first htaccess is the problem (the path after the private should be added to the new url). Try something like

 RewriteRule ^/private/?(.*) /private/app/web/$1 

or (generated using http://www.htaccessredirect.net/ )

 RedirectMatch 301 /private(.*) /private/app/web/$1 
0
source

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


All Articles