1

我们正在将旧版本 Zend Framework 上的旧项目转移到 Laravel。为了让生活更轻松,我们正在考虑同时运行这两个应用程序。

假设我们在 Laravel 中建立了一个新博客,这是完成此任务的最简单方法:

http://example.com/blog -> 在 /var/www/laravel-project/public/index.php 中运行 index.php http://example.com/something_else -> 在 /var/www 中运行 index.php /zend-project/public/index.php

.htaccess 解决方案

Options +FollowSymLinks
RewriteEngine On

RewriteRule ^blog/(.+)$ /laravel/public/index.php [NC,QSA,L]
RewriteRule ^assets/(.+) /laravel/public/assets/$1 [NC,QSA,L]

RewriteRule ^images/(.+) /zend/public_html/images/$1 [NC,QSA,L]
RewriteRule ^(.+)$ /zend/public_html/index.php [NC,QSA,L]
4

2 回答 2

3

您可以设置仅针对特定段的重写条件,并将它们路由到其中一个框架,如下所示(警告:未经测试)...

# Laravel Requests
RewriteCond $1 ^(blog)
RewriteRule ^ laravel/public/index.php [L]

# Zend Requests
RewriteCond $1 ^(something_else)
RewriteRule ^ zend/public/index.php [L]

# Assets
RewriteCond $1 !^(index.php)
RewriteRule ^ all/public/$0 [L]

对于 Laravel,您需要更改 public/index.php 和其他地方的一些路径,以便它知道它在哪里;我认为这对 Zend 也一样吗?

于 2013-06-03T09:11:42.003 回答
0

我的解决方案:

Options +FollowSymLinks
RewriteEngine On

RewriteRule ^blog/(.+)$ /laravel/public/index.php [NC,QSA,L]
RewriteRule ^assets/(.+) /laravel/public/assets/$1 [NC,QSA,L]

RewriteRule ^images/(.+) /zend/public_html/images/$1 [NC,QSA,L]
RewriteRule ^(.+)$ /zend/public_html/index.php [NC,QSA,L]
于 2013-06-03T11:30:25.153 回答