I have a simple structure:
Root
|-- [app] (Symfony Application)
| |-- [app]
| |-- [bin]
| |-- [src]
| |-- [vendor]
| |-- [web]
| |-- .htaccess (Symfony htaccess)
|
|-- [wp-admin]
|-- [wp-content]
|-- [wp-include]
|-- .htaccess (Root htaccess)
I need following mapping:
http://example.com ==> Wordpress
http://example.com/app ==> Symfony Application
This is what I have:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^app(.*)$ app/web/$1 [L,QSA]
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
DirectoryIndex app.php
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
<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}/$1 [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>
The problem is that, Symfony routes are not resolved:
No route found for "GET /"
Is there any simple solution to this?
This solution requires ssh access.
Abandon all solutions based on htaccess rules . Try to use symbolic link instead ln -s command
The best idea here is to put each project in seperate folder otuside folder where your domain is pointing (let's name it here as public_html)
ROOT
|
-[Symfony]
-[WP]
-[public_html] (folder where your domain is pointing)
and now - remove public_html - add symbolic link to wp ( with name of public html) - include wp create symbolic link to symfony/web
ROOT
|
-[Symfony]
-[WP]
-- [app] (symbolic link to symfony/web)
-[public_html] (symbolic link to WP )
As alternative i think that possible is to redirect request from symfony to wp and then push wp response to user(from symfony) . I seen solutions like this ( it's used when you building new app on top of legacy system ) . But this is more problematic than symbolic link ( you can see the idea here https://www.enotogorsk.ru/en/2014/07/22/symfony-legacy-bridge/)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With