Reputation: 2277
I have an apache server and my projects are inside /var/www/html/
Inside there I created a new project using composer like composer create-project symfony/website-skeleton myproject
.
Then inside my project I ran the command composer require symfony/apache-pack
which added an .htaccess file inside public
folder containing the default .htaccess
of symfony.
When I accessed my server like http://192.168.0.2/myproject
I got the folder list that apache serves if it doesn't find an index.php
file because it accessed the default symfony folder in /var/www/html/myproject
and not the public folder.
So inside the folder /var/www/html/myproject
which is a symfony project I added the following .htaccess file.
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /myproject/
RewriteRule ^$ public/ [L]
RewriteRule (.*) public/$1 [L]
</IfModule>
No I when I visit http://192.168.0.2/myproject
I get an error that No route found for "GET /myproject/"
which means that symfony now considers /myproject
as part of a route.
Is there a solution for this. I suggested solution that I got from symfony slack would be to have the project inside another folder and symlink only the public folder.
Something like:
lrwxrwxrwx 1 root root 59 gmponos 9 19:26 myproject -> /home/gmponos/Projects/myproject/public/
This is a solution but I really need to have the whole project under /var/www/html/
and not symlink the public folder.
Also another solution according to the official documentation is editing the apache config and change the document root from /var/www/html/myproject to /var/www/html/myproject/public but I need the configuration to stay inside the project and not change the apache config.
Is there any solution?
Upvotes: 1
Views: 802
Reputation: 188
Is there any solution? No Solution for what you are requesting :
You must have the rights to configure Apache to adjust the document root to either :
Putting whole code in code in /var/www/html directory, and give free remote access through Web (Apache) is very risky, for production environments.
Upvotes: 0