【问题标题】:Zend Framework with subdomainsZend 框架与子域
【发布时间】:2012-02-28 01:18:13
【问题描述】:

我在让 zend 框架与我的服务器上的子域很好地配合时遇到问题。我在 ubuntu 11.10 上运行了一个 LAMP 堆栈,我还使用了一个动态 dns 服务,我在其中定义了我的区域记录。所以基本上我的 dns 设置如下:

DNS: 在一家公司注册并将我的域名指向此处的动态 DNS 名称服务器。

使用动态 DNS 主机,我有 3 条已定义的 A 类型区域记录:

mydomain.com 000.00.0.0
www.mydomain.com 000.00.0.0
*.mydomain.com 000.00.0.0  <-- wildcard to catch all subdomains

Apache 设置

/etc/apache2/sites-available :: /sites-enabled 我有mydomain 的默认设置和mysubdomain.mydomain.com 的另一个虚拟主机

/var/www : 我有 mydomain.com/public /var/www/public 文件夹作为其文档根目录

/var/www/mysubdomain: 我有 mysubdomain.mydomain.com 使用 /var/www/mysubdomain/public 文件夹作为其根目录

我认为所有这些设置都正确,因为我正确地向www.mydomain.com 提供任何请求,并且我也正确地向www.mysubdomain.mydomain.com 提供任何请求。

但是当我发出www.mysubdomain.mydomain.com/:controllerwww.mysubdomain.mydomain.com/:controller/:action 之类的请求时,我收到来自服务器的 404 Not Found 并显示以下消息:

The requested URL /controller/action was not found on this server.

我认为这是我的 .htaccess 的问题,它在

中以以下方式设置

我的 .htaccess

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule .* index.php 

问题是,当我当前尝试访问的应用程序被设置并作为普通域(如www.mysubdomain.com)访问时,一切正常。

【问题讨论】:

    标签: zend-framework .htaccess apache2 subdomain vhosts


    【解决方案1】:

    我正在使用以下 .htaccess:

    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} -s [OR]
    RewriteCond %{REQUEST_FILENAME} -l [OR]
    RewriteCond %{REQUEST_FILENAME} -d
    RewriteRule ^.*$ - [NC,L]
    RewriteRule ^.*$ index.php [NC,L]
    

    也许你可以尝试提供结果。

    【讨论】:

    • 使用 .htaccess 获得 500 内部服务器错误,这很奇怪,因为如果我没记错的话,这是 zf 推荐的默认 .htaccess
    • 你能用 在 /public 文件夹中,看看你是否可以访问它?或者您是否也为此获得 500 分?
    • 您是否在 httpd.conf 中为您的虚拟主机设置了AllowOverride FileInfo?这是授予 .htaccess 文件启用重写引擎的权限所必需的。
    • 抱歉,发现我的错误。这是 apache 的新安装,我必须运行 a2enmod rewrite 才能启用 url 重写。虽然我原来的 .htaccess 仍然有效,但我给 Goeran 的答案是花时间。
    猜你喜欢
    • 1970-01-01
    • 2011-12-15
    • 1970-01-01
    • 2011-08-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-10-14
    • 1970-01-01
    相关资源
    最近更新 更多