使用cpanel在服务器上设置laravel项目 [英] Setting up a laravel project on a server with cpanel

查看:191
本文介绍了使用cpanel在服务器上设置laravel项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将laravel项目设置为该面板的主页,出于隐私方面的考虑,我将模糊网站名称等。我已重定向到该目录,例如

I"m trying to set up a laravel project as the main page for this cpanel, I'll be blurring out the website name and such for privacy reasons. I've made a redirect to the directory like this

当我单击目录链接时,我被发送到该项目,但遇到了这些错误

When I click on the directory link, I get sent to the project but get these errors


拒绝应用' http://page_example.com/css/app.css?id=4513b702e5714c4239c0 ​​',因为它的MIME类型('text / html')不是受支持的样式表MIME类型,并且严格的MIME检查是

Refused to apply style from 'http://page_example.com/css/app.css?id=4513b702e5714c4239c0' because its MIME type ('text/html') is not a supported stylesheet MIME type, and strict MIME checking is enabled.

如果我尝试进入该网站,则该页面没有 / ex_server / public 我被重定向到 page_example.com/ex_server / public ,我被禁止使用403。

If I try and go into the website just the page without the /ex_server/public I get redirected to just page_example.com/ex_server without the /public and I get a 403 forbidden.

我认为重定向甚至都没有用,因为在public_html文件的index.php文件中,如果我只留下了前两个默认代码块,则将我重定向到默认的a2hosting页面,但是如果我注释掉第一个内容并仅保留了手动重定向,则我确实重定向到了该页面。

I don't think the redirect is even working, because in the index.php file in the public_html file I have this, If I leave only the first two default blocks of code then I get redirected to the default a2hosting page, but if I comment that first stuff out and only leave the manual redirect then I do get redirected to that page.

<?
if (file_exists('./index.html')) {
  rename('./index.php', './a2-default-index.php');
  header('refresh:1');
}

$ch = curl_init('http://default.a2hosting.com/');
curl_exec($ch); curl_close($ch);
?>

<?php
header("Location: http://www.page_example.com/ex_server");
die();
?>

如何解决这些错误并使重定向正常工作?

How can I fix these errors and get the redirect working correctly?

推荐答案

您可以尝试添加此文件


.htaccess文件public_html文件夹

.htaccess file to public_html folder



RewriteEngine on 

# for example.com rewrite landing page to subdirectory/index.php
RewriteCond %{HTTP_HOST} ^(www\.)?example\.com$ [NC]
RewriteRule ^/?$ subdirectory/index.php[L]

# for example.com rewrite all other URIs to subdirectory/uri
# (?!subdirectory/) is a negative lookahead that stops rewrite then uri 
# already starts with /subdirectory/
RewriteCond %{HTTP_HOST} ^(www\.)?example\.com$ [NC]
RewriteRule ^(?!subdirectory/)(.+)$ subdirectory/$1 [L,NC]

将子目录更改为home,并将示例更改为您的域名。

Change subdirectory to home and example to your domain name.

这篇关于使用cpanel在服务器上设置laravel项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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