【问题标题】:Having two different php frameworks on one single domain在一个域上拥有两个不同的 php 框架
【发布时间】:2013-06-03 19:30:25
【问题描述】:

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

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

http://example.com/blog -> 在 /var/www/laravel-project/public/index.php 中运行 index.php http://example.com/something_else -> 在 /var/www/zend-project/public/index.php 中运行 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]

【问题讨论】:

  • 您是否拥有对 Apache 配置的完全访问权限,或者这是共享主机?
  • @halfer 我拥有服务器的完全访问权限

标签: php .htaccess zend-framework ubuntu laravel


【解决方案1】:

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

# 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 也一样?

【讨论】:

  • 我不认为我的示例可以开箱即用 - 像这样的 apache 重写规则几乎需要 apache 学位才能构建和理解;)
  • @Emil,打开 mod_rewrite 日志以了解发生了什么。查看手册了解如何操作。
【解决方案2】:

我的解决方案:

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]

【讨论】:

    猜你喜欢
    • 2015-08-30
    • 1970-01-01
    • 2019-06-23
    • 1970-01-01
    • 2012-04-24
    • 2014-09-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多