【发布时间】:2014-06-24 01:02:48
【问题描述】:
我正在尝试将 silverstripe 站点从一台主机服务器移动到新的主机服务器。但是,我在网站上不断收到 404 错误,并记录错误 [Wed May 07 15:20:10 2014] [error] [client xxx.xx.xx.xxx] File does not exist: /home/examplesite/public_html /sys_cpanel,引用者:http://xxx.xx.xx.xxx/~examplesite/。
该站点使用的是 silverstripe 2.4.5,在旧服务器上一切正常。新的托管公司正在使用带编号的预览链接,例如http://xxx.xx.xx.xxx/~examplesite/,以便您在关闭实时站点之前确保站点正常运行。有人可以指出我正确的方向吗?谢谢。
这是我所做的: 1. 将所有 ftp 文件移至新服务器 2.迁移的数据库 3.通过mysite文件夹中的_config.php建立数据库连接 4. 修改.htaccess
这是我注释掉第一行的 .htaccess 文件,因为它指向实时站点,我还尝试将预览地址放入 (http://xxx.xx.xx.xxx/~examplesite/),但也不起作用。
###RewriteRule mambo/ http://www.examplesite.com/ [R=301,L] ###
### SILVERSTRIPE START ###
<Files *.ss>
Order deny,allow
Deny from all
Allow from 127.0.0.1
</Files>
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} !(\.gif$)|(\.jpg$)|(\.png$)|(\.css$)|(\.js$)
RewriteCond %{REQUEST_URI} ^(.*)$
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule .* sapphire/main.php?url=%1&%{QUERY_STRING} [L]
RewriteCond %{REQUEST_URI} /assets/Uploads/members/ANZJAT [NC]
RewriteCond %{REQUEST_FILENAME} \.(pdf|zip|rar|7z|doc|docx|xls|xlsx|ppt|pptx)$ [NC]
RewriteRule .* filedownloadpermission?file=%{REQUEST_FILENAME}&%{QUERY_STRING} [L,NC]
</IfModule>
### SILVERSTRIPE END ###
这是 mysite 文件夹中的 _config.php,我尝试将其更改为 dev 而不是 live,这也不起作用。
<?php
global $project;
$project = 'mysite';
global $databaseConfig;
$databaseConfig = array(
"type" => "MySQLDatabase",
"server" => "servername",
"username" => "admin",
"password" => "xxxxxxx",
"database" => "examplesite_database",
);
MySQLDatabase::set_connection_charset('utf8');
Director::set_dev_servers(array(
'localhost',
'127.0.0.1',
));
Director::set_environment_type("live");
SSViewer::set_theme('themename');
Email::setAdminEmail('info@examplesite.com');
Geoip::$default_country_code = "countryname";
DataObject::add_extension('Member', 'MemberExtension');
DataObject::add_extension('SiteConfig', 'CustomSiteConfig');
Security::set_default_login_dest('members');
SortableDataObject::add_sortable_class('EventSession');
SortableDataObject::add_sortable_class('ClientType');
define('NON_MEMBER_TYPE', 'non-member');
Director::AddRules(100, array('filedownloadpermission/$Action/$ID/$OtherID' => 'FileDownloadPermission_controller'));
?>
任何帮助将不胜感激,谢谢。
【问题讨论】:
-
另外一种可能更好的是,将
RewriteBase /更改为RewriteBase /~examplesite。只需在网站上线后恢复它,因为它只是在您尝试通过http://xx.xx.xx.xx/~examplesite/查看网站时。 -
嗨 Shane,抱歉回复晚了,非常感谢您的提示,它简单地解决了我的问题。谢谢你。您想在下面回答,以便我选择您的答案吗?如果没有,我稍后会自己关闭它。感谢您的帮助。
标签: php .htaccess hosting cpanel silverstripe