【问题标题】:Apache rewrite engine not working on subdomainApache重写引擎不适用于子域
【发布时间】:2013-04-05 09:51:22
【问题描述】:

我正在使用 Yii 框架并在 .htaccess 中有以下代码:

RewriteEngine on

# if a directory or a file exists, use it directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

# otherwise forward it to index.php
RewriteRule . index.php

我在 URL 管理器中使用此代码来制作 SEO-URL:

'urlManager'=>array(
  'urlFormat'=>'path',
  'rules'=>array(
  ''=>'site/index',
  'admin'=>'admin/default/login',
  '<action:\w+>'=>'site/<action>',
  array('page/view', 'pattern'=>'/<url:(\w|-)+>.html', 'caseSensitive'=>false),
  array('category/view', 'pattern'=>'category/<url:(\w|-)+>', 'caseSensitive'=>false),
  array('product/view', 'pattern'=>'product/<url:(\w|-)+>', 'caseSensitive'=>false),
),
  'showScriptName'=>false,
),

它可以在我的本地计算机上完美运行。但是当我试图在我的 VDS 上应用它时,我会得到服务器,只有当此代码适用于子域时,例如:我有 blah-blah.com - 此代码有效,但如果我有 new.blah-blah.com(这应该是不同的网站,与 blah-blah.com 没有任何共同之处)我收到以下错误(内部服务器错误 500): 内部服务器错误

服务器遇到内部错误或配置错误,无法完成您的请求。

请联系服务器管理员,[我的电子邮件],并告知他们错误发生的时间,以及您所做的任何可能导致错误的事情。

服务器错误日志中可能会提供有关此错误的更多信息。

在 apache 的日志中我一无所获。

【问题讨论】:

    标签: mod-rewrite yii apache2


    【解决方案1】:

    您可以将错误记录到文件或发送到邮件。

    在你的 config/main.php 中

     'log'=>array(
                        'class'=>'CLogRouter',
                        'routes'=>array(
                                array(
                                        'class'=>'CFileLogRoute',
                                        'levels'=>'error, warning',
                                ),
                                array(
                                        'class'=>'CEmailLogRoute',
                                        'levels'=>'error, warning',
                                        'emails'=>'yourmail@yourdomain.com',
                                ),
    
                        ),
                 ),
    

    【讨论】:

    • 我已经记录了错误和警告,但问题是,我得到的正是 apache 的 500 错误页面,而不是 Yii 生成的内容。
    猜你喜欢
    • 2023-03-31
    • 2014-02-22
    • 1970-01-01
    • 2010-09-08
    • 1970-01-01
    • 2017-06-04
    • 1970-01-01
    • 2012-11-30
    • 1970-01-01
    相关资源
    最近更新 更多