Silverstripe mod_rewrite的问题(我想) [英] Silverstripe mod_rewrite issue (I think)

查看:152
本文介绍了Silverstripe mod_rewrite的问题(我想)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有一个网站,我一直在努力,一直工作正常在我的本地开发和现场开发环境上是给我的问题,当我尝试将它部署到活动服务器(客户端希望与他们现有的托管主机它供应商)。

A site I've been working on, which has been working fine on my local dev and live dev environments is giving me issues when I try to deploy it to a live server (the client wants to host it with their existing hosting provider).

我上传的网站服务器和更新数据库配置,因为我已经没有问题,以前做过很多次我的两个和其他的服务器。但是这一次,我是psented其中$ p $:

I uploaded the site to the server and updated the database config as I have done many times before on both my and other's servers without issue. This time, however, I was presented with:

SilverStripe Framework requires a $databaseConfig defined.

当我删除从根文件夹中的.htaccess文件,该网站出现了,但是,所有的网址出现像这样:

When I removed the .htaccess file from the root folder, the site appeared, however, all the URLs appeared like so:

www.domain.com/index.php/page_name

经过几次的搜索,我碰到一个解决的index.php问题;下面的内容添加到我_config文件

After a few searches, I came across a solution to the index.php issue; to add the following to my _config file

Director::setBaseURL('/');

我这样做和网址的正确显示,但是导航到他们会给我404。

I did this and the URL's appeared correctly, however navigating to them would give me a 404.

我恢复了htaccess的文件,并以该块缩小了:

I reinstated the htaccess file and narrowed it down to this block:

RewriteCond %{REQUEST_URI} ^(.*)$
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_URI} !\.php$
    RewriteRule .* framework/main.php?url=%1 [QSA]

当这是地方,我得到上面的数据库配置错误提到的,当它不存在,我的网址产生404

When this is in place, I get the database config error mentioned above, when it's not there, my urls produce 404s

有没有人有任何见解,以什么可以怎么回事?我已经有很多来回的主机和他不是很见地,不能提供任何意见,我不是天才,当涉及到的东西这一边。

Does anyone have any insight as to what can be going on here? I've had a lot of back and forth with the host and he's not very knowledgable and can't offer any advice and I'm no genius when it comes to this side of things.

推荐答案

我会认为你正在使用SilverStripe 3.1+所以导演的配置可以/应该被放置在你的YAML配置文件(静态会去precated):

I'll assume you are using SilverStripe 3.1+ so the Director config could/should be placed in your YAML config file (the static will be deprecated):

Director:
  alternate_base_url: '/'

虽然这有助于主要问题 base_tag

主要ModRewrite问题,但是可能通过添加解决的的RewriteBase

The main ModRewrite issue might however be solved by adding a RewriteBase:

RewriteEngine On
RewriteBase '/'

您可以使用/如果没有公共根目录SS安装研究。这通常是自动被SilverStripe安装程序处理通过检查 $基地=目录名($ _ SERVER ['SCRIPT_NAME']); 和其他小东西。检查 install.php5 线1483,你也许可以用它来计算出你的RewriteBase。

You can use '/' or the folder SS is installed in if not the public root. This is usually automatically handled by the SilverStripe installer by checking $base = dirname($_SERVER['SCRIPT_NAME']); and other little things. Check install.php5 line 1483, you might be able to use this to figure out your RewriteBase.

如果还是不行,请尝试全新安装,而不是复制到服务器本地进行安装。

If that doesn't work, try a fresh install instead of copying to the server your local install.

这篇关于Silverstripe mod_rewrite的问题(我想)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆