Laravel主页提供404但index.php有效

时间:2013-02-02 20:20:49

标签: php .htaccess laravel

我正在我网站的子文件夹中创建自定义cms。我在www.mysite.com/cms/上安装了一份新的laravel副本< - 应用程序,捆绑包,公共等等。

由于共享托管,我无法创建虚拟主机,但我设法通过添加

来删除/ public在网址中的需要
RewriteCond %{REQUEST_URI} !^/cms/public/.*$
RewriteRule ^(.*)$ /cms/public/$1 [L]

在我的cms文件夹中的.htaccess文件中。

问题是,干净的网址www.mysite.com/cms/public/显示了Laravel首页。但www.mysite.com/cms/给了我404错误,www.mysite.com/cms/index.php显示了Laravel启动页面。

我已将application.php中的url数组元素设置为

'url' => 'http://www.mysite.com/cms/',

和索引元素

'index' => '',

有没有人遇到过这个问题?

2 个答案:

答案 0 :(得分:0)

要在共享主机上使用laravel,我建议您尝试this

顺便说一句,在你的.htaccess中,你只是重定向到公共目录中对index.php的所有不存在的请求查询。因为您应该使用url.com/public访问。

答案 1 :(得分:0)

也许如果您要将public文件夹的内容上传到/cms,将其他文件夹上传到/cms_system,您可以更改paths.php文件以反映此内容?

所以,你有这个:

/cms
    (contents of the public folder, with .htaccess)
/cms_system
    /application
    /bundles
    /laravel
    /storage
    (etc)

您的路径将如下所示:

$paths['sys'] = 'system';
$paths['bundle'] = 'bundles';
$paths['app'] = 'application';
$paths['storage'] = 'storage';
$paths['public'] = '../cms';

我还没有测试过,但它应该可行。如果有任何问题,请告诉我,并会看到可以相应更改的内容。