【问题标题】:Page doesn't exist error页面不存在错误
【发布时间】:2015-03-31 16:36:49
【问题描述】:

我正在尝试安装一个名为 JobberBase 的脚本,但没有成功... 问题是我的主页正常加载,但是当我点击任何链接时,它只是说该页面不存在......这是一个活生生的例子:http://onboardcloud.com 这是我的配置文件:

<?php
/**
 * Define environments
 *
 */

// local
$__instances['local'] = array(
    // The prefix should be a unique part of the url (not including protocol name or auth info; see below).
    'prefix' => 'localhost',
    // mysql credentials
    'db_host' => 'localhost',
    'db_port' => 3306,
    'db_user' => 'root',
    'db_password' => 'password',
    'db_name' => 'jobberbase',
    'db_prefix' => '',
    // your site's full url
    'app_url' => 'http://localhost/',
    // language to use
    'lang_code' => 'en',
    // error reporting
    'ini_error_reporting' => E_ALL,
    'ini_display_errors' => 'On',
    // environment setting 1 (use 'local' for localhost/testing OR 'online' for live, production environment)
    'location' => 'online',
    // environment setting 2 (use 'dev' together with 'local' in the previous setting OR 'prod' with 'online')
    'environment' => 'prod',
    //'apache_mod_rewrite', 'iis_url_rewrite' -microsoft URL Rewrite module, 'iis_isapi_rewrite'
    'rewrite_mode' => 'apache_mod_rewrite'
);

// live
$__instances['live'] = array(
    'prefix' => 'onboardcloud.com',
    'db_host' => 'localhost',
    'db_port' => 3306,
    'db_user' => 'root',
    'db_password' => 'password',
    'db_name' => 'jobberbase',
    'db_prefix' => '',
    'app_url' => 'http://onboardcloud.com/',
    // language to use
    'lang_code' => 'en',
    'ini_error_reporting' => E_ALL,
    'ini_display_errors' => 'Off',
    'location' => 'online',
    'environment' => 'prod',
    'rewrite_mode' => 'apache_mod_rewrite'
);


// http requests
if (isset($_SERVER['HTTP_HOST']) && isset($_SERVER['REQUEST_URI']))
{
    $_compare_to = $_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
}

// setup current instance
foreach ($__instances as $__instance)
{
    if (strstr($_compare_to, $__instance['prefix']))
    {
        define('DB_HOST', $__instance['db_host']);
        define('DB_PORT', $__instance['db_port']);
        define('DB_USER', $__instance['db_user']);
        define('DB_PASS', $__instance['db_password']);
        define('DB_NAME', $__instance['db_name']);
        define('DB_PREFIX', $__instance['db_prefix']);

        // values kind of redundant, they indicate wether this is a live/production or dev/testing environment
        define('LOCATION', $__instance['location']);
        define('ENVIRONMENT', $__instance['environment']);

        $app_url = $__instance['app_url'];

        $indexOfLastSlash = strrpos($app_url, "/");
        $expectedIndexOfLastSlash = strlen($app_url) - 1;

        // manually add an ending slash to the app_url if the user didn't specify it
        if ($indexOfLastSlash && $indexOfLastSlash != $expectedIndexOfLastSlash )
            $app_url .= '/';

        // base url of the app
        define('APP_URL', $app_url);
        define('REWRITE_MODE', $__instance['rewrite_mode']);

        // error reporting
        ini_set('error_reporting', $__instance['ini_error_reporting']);
        ini_set('display_errors', $__instance['ini_display_errors']);

        define('LANG_CODE', $__instance['lang_code']);

        break;
    }
}

if(!defined('DB_HOST'))
{
    die('None of the configured JobberBase instances matched your request!<br />If you are an admin of this JobberBase installation, you may want to review the \'prefix\' values of the configured JobberBase instances in config.envs.php.');
}
?>

这是我的 .htaccess 文件:

ErrorDocument 404 /page-unavailable/

<files ~ "\.tpl$">
order deny,allow
allow from all
deny from none
AllowOverride All
</files>
<Directory /var/www/>
                Options Indexes FollowSymLinks MultiViews
                AllowOverride All
                Order allow,deny
                allow from all
 </Directory>
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php [L]

我使用 Ubuntu 作为服务器。我安装了 Apache2、PHP、MySQL、suPHP 和 PHPmyAdmin。 任何帮助将不胜感激!

【问题讨论】:

  • 我认为您的 apache 配置 AllowOverride All 中没有启用 htaccess。因为如果你这样做了,你应该得到一个内部服务器错误。 Directory 指令不能在 .htaccess 中使用。您的 htaccess 非常错误。
  • @PanamaJack 谢谢,但我该如何解决呢?你能留下一个答案,如果它有效,我会接受它;)

标签: php html .htaccess


【解决方案1】:

我不知道 jobberbase,但你的 htaccess 文件应该是这样的。

RewriteEngine on
Options +FollowSymlinks

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php [L]

ErrorDocument 404 /page-unavailable/

<Files ~ "\.tpl$">
order deny,allow
deny from all
</Files>

下面的内容应该在您的 Apache vhost 配置文件中。在 Ubuntu 上,它位于 /etc/apache2/sites-available/default。如果不是默认值,那么无论您在站点可用目录中调用您的站点。如果它已经存在,则无需更改任何内容,只需确保将 AllowOverride 设置为 All

<Directory /var/www/>
   Options Indexes FollowSymLinks MultiViews
   AllowOverride All
   Order allow,deny
   allow from all
 </Directory>

如果更新 vhost 文件,请确保重新启动 apache。

【讨论】:

  • 您好!它似乎仍然不起作用...我更改了.htaccess,转到/etc/apache2/sites-available/并编辑了文件:000-default.conf。它没有“AllowOverride all”行,所以我添加了一个,但仍然没有...文件中的路径是正确的...
  • 你好!我现在启用了配置文件,但我收到一条错误消息,指出 AllowOverride all 是不允许的?谢谢:)
  • 天哪!它刚刚奏效!非常感谢!你不知道我现在有多感激! :D
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2014-01-19
  • 2011-11-07
  • 1970-01-01
  • 2011-03-15
  • 2015-06-14
  • 2011-04-20
  • 1970-01-01
相关资源
最近更新 更多