【问题标题】:Setting up a laravel project on a server with cpanel使用 cpanel 在服务器上设置 laravel 项目
【发布时间】:2019-11-14 19:36:00
【问题描述】:

我正在尝试设置一个 laravel 项目作为此 cpanel 的主页,出于隐私原因,我将模糊网站名称等。我已经重定向到这样的目录

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

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

如果我尝试只进入没有/ex_server/public 的页面,我会被重定向到没有/publicpage_example.com/ex_server,并且我会收到403 禁止。

我认为重定向甚至不起作用,因为在 public_html 文件的 index.php 文件中我有这个,如果我只保留前两个默认代码块,那么我会被重定向到默认的 a2hosting 页面,但是,如果我将第一个内容注释掉并且只保留手动重定向,那么我确实会被重定向到该页面。

<?
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();
?>

如何修复这些错误并让重定向正常工作?

【问题讨论】:

    标签: cpanel


    【解决方案1】:

    你可以试试这个添加这个文件

    .htaccess 文件到 public_html 文件夹

    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 并将 example 更改为您的域名。

    【讨论】:

    • 我已更改此设置,但现在找不到 404
    猜你喜欢
    • 2020-05-20
    • 2020-04-01
    • 2017-04-26
    • 1970-01-01
    • 2014-12-08
    • 2020-06-28
    • 2020-10-30
    • 1970-01-01
    • 2020-12-17
    相关资源
    最近更新 更多