我正在尝试将 Apache 配置为必须使用不同的 symfony 项目(每个项目都有自己安装的框架)在同一个域下,但我无法使用文件夹使其工作。
这就是我想要的:
我可以使用子域使其工作,但对我来说不是首选解决方案,因为我最终拥有疯狂的子域,例如:
我在 Apache 中使用此配置使其与子域一起使用:
<VirtualHost 127.0.0.1:8080>
ServerName projectone.mydomain.com
DocumentRoot "/home/projectone/web"
DirectoryIndex frontend.php
<Directory "/home/projectone/web">
Options -Indexes IncludesNOEXEC FollowSymLinks -MultiViews
AllowOverride None
Allow from All
RewriteEngine On
# we check if the .html version is here (caching)
RewriteRule ^$ index.html [QSA]
RewriteRule ^([^.]+)$ $1.html [QSA]
RewriteCond %{REQUEST_FILENAME} !-f
# no, so we redirect to our front web controller
RewriteRule ^(.*)$ frontend.php [QSA,L]
</Directory>
Alias /sf /home/projectone/lib/vendor/symfony/data/web/sf
<Directory "/home/projectone/lib/vendor/symfony/data/web/sf">
AllowOverride All
Allow from All
</Directory>
</VirtualHost>
关于如何实现文件夹解决方案的任何想法?
提前致谢,
埃内科
最佳答案
我一直这样做。这是相关的 Apache 配置。我也设置了custom error handlers对于每个 symfony 应用程序。
# make sure your symfony install dir is available
<Directory "/var/www/symfony1.4">
AllowOverride All
Allow from all
</Directory>
# each app under http://mysite/myapp gets a section like this
Alias /myapp/sf "/var/www/symfony1.4/data/web/sf"
Alias /myapp "/var/www/vhosts/myvhost/sf_apps/myapp/web"
<Directory "/var/www/vhosts/myvhost/sf_apps/myapp/web">
AllowOverride All
Allow from all
ErrorDocument 404 /myapp/default/error404
ErrorDocument 500 /myapp/myThemePlugin/errors/error500.php
</Directory>
您还需要在您的
web/.htaccess
中修改此行文件。# uncomment the following line, if you are having trouble
# getting no_script_name to work
RewriteBase /myapp
关于apache - 如何配置 Apache 在同一个域中有两个 symfony 项目(不使用子域)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2148182/