2

共有ウェブホストでZendアプリケーションを作成しようとしていますが、php.iniなどにアクセスできません。

Zendがセットアップされ、インデックスコントローラー/ビュー用に機能しています。しかし、「mysite.com/About」と言って別のコントローラー/ビューにアクセスしようとすると、次のエラーが発生します。

Not Found
The requested URL /home/vhosting/g/vhostxx/domains/mysite.com/htdocs/projectname/public/index.php was not found on this server.

私のフォルダ構造は次のようになります: http: //framework.zend.com/wiki/display/ZFPROP/Zend+Framework+Default+Project+Structure+-+Wil+Sinclair(ポイント9を参照)

ルート(/home/vhosting/g/vhostxx/domains/mysite.com/htdocs/projectname)の.htaccessは次のようになります。

php_value include_path "/domains/mysite.com/htdocs/www/library"

Options All -Indexes

php_flag display_errors on

RewriteEngine on
RewriteCond %{HTTP_HOST} ^mysite.com$ [NC,OR]
RewriteCond %{HTTP_HOST} ^www.mysite.com$
RewriteCond %{REQUEST_URI} !public/
RewriteRule (.*) /public/$1 [L]

また、パブリックフォルダの.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]

これは、パブリックフォルダー内のindex.phpです。

// Define path to application directory
defined('APPLICATION_PATH')
|| define('APPLICATION_PATH', realpath(dirname(__FILE__) . '/../application'));

// Define application environment
defined('APPLICATION_ENV')
|| define('APPLICATION_ENV', (getenv('APPLICATION_ENV') ? getenv('APPLICATION_ENV') :  'production'));

// Ensure library/ is on include_path
set_include_path(implode(PATH_SEPARATOR, array(
realpath(APPLICATION_PATH . '/../library'),
get_include_path(),
)));

/** Zend_Application */
require_once 'Zend/Application.php';

// Create application, bootstrap, and run
$application = new Zend_Application(
APPLICATION_ENV,
APPLICATION_PATH . '/configs/application.ini'
);
$application->bootstrap()
        ->run();

そして、アプリケーションフォルダ内の(空の)ブートストラップ:

class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
{

}

The controller I'm trying to access is: projectname/application/controllers/AboutController.php Which should be accessable via mysite.com/About but instead I recieve the message stated earlier.

I really have no idea what I'm doing wrong or what I'm missing. Can anyone tell me how to solve this or how to debug this?

On a sidenote: My host automaticly translates

mysite.com/htdocs/projectname/

into

mysite.com/htdocs/www/

on ftp, not sure if that is a problem or happens when accessing it via http

4

1 に答える 1

4

In the htaccess file in your public folder, change:

RewriteRule ^.*$ index.php [NC,L]

to include a leading slash:

RewriteRule ^.*$ /index.php [NC,L]

Apache guesses what a rewrite rule's target is, whether it's URI-path for file-path, and it looks like it is incorrectly guessing that it's a file path. You could alternatively add a base to your htaccess file:

RewriteBase /
于 2012-08-26T18:00:36.763 に答える