使用Apache在同一域上托管两个web应用程序



这可能很奇怪,但我需要为两个不同的应用程序设置一个域,一个是用Symfony3构建的,而另一个则是用Wordpress构建的。两个网站都在同一台服务器上。

www.example.com->wordpress

www.example.com/customizedslug->symfony3

使用Apache2可以实现这一点吗?

感谢您的帮助

您可以使用Alias指令将所有匹配pattern/custom slug/*的请求映射到Symfony应用程序。所有其他URL都将通过wordpress提供。

样本主机:

<VirtualHost *:80>
ServerName www.example.com
ServerAdmin webmaster@localhost
DocumentRoot /your_web_root/www_example_com/wordpress/
# All URLs begining with /custom-slug will be fetched from the symfony app
Alias "/custom-slug" "/your_web_root/www_example_com/symfonyApp/web/"
<Directory /your_web_root/www_example_com/wordpress/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
<Directory /your_web_root/www_example_com/symfonyApp/web/>
AllowOverride None
Order Allow,Deny
Allow from All
<IfModule mod_rewrite.c>
Options -MultiViews
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ app.php [QSA,L]
</IfModule>
</Directory>
</VirtualHost> 

最新更新