duanlu0559 2016-04-03 14:27
浏览 48
已采纳

Laravel live project的路由功能不正常......为什么?

I have a subdomain http://206.217.128.227/~obts/ . I hosted my laravel project on this subdomain . This domain's cpanel structer iscpanels folder structures

When I click on any href property the url is http://206.217.128.227/something but then i have 404 error . But if I give url manually http://206.217.128.227/~obts/something then i get the correct page. I have pasted public folder's content on public_html folder. And all other contents of project on laravel folder. I modified index.php file as

require __DIR__.'/../laravel/bootstrap/autoload.php';
$app = require_once __DIR__.'/../laravel/bootstrap/app.php';

I added paths.php file manually and modified 'public' property as

'public' => __DIR__.'/../public_html',

My .env file is

APP_ENV=local
APP_DEBUG=true
APP_KEY=something
APP_URL=http://206.217.128.227/

DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=obts_data
DB_USERNAME=obts_admin
DB_PASSWORD=password

CACHE_DRIVER=file
SESSION_DRIVER=file
QUEUE_DRIVER=sync

REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null
REDIS_PORT=6379

MAIL_DRIVER=smtp
MAIL_HOST=mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null

Now what wrong i am doing ?

  • 写回答

1条回答 默认 最新

  • duanliyi5997 2016-04-04 01:31
    关注

    The question has already been answered by me in the comments. This little article will summarize what was asked and what was wrong.

    Question: OP reported that he set up a new L5.2 project where his "views" folder is outside his L5.2 project structure (as shown in the image below). He modified the index.php file to include this new view path. However his URLs of type http://206.217.128.227/something were not working whereas URLs of type http://206.217.128.227/~obts/something were working fine.

    Answer: The issue here is that his generated URLs does not contain ~obts in the path and thus L5.2 was reporting errors. Pretty easy fix.

    However, I would like to suggest a few things here:

    1. Never show passwords in your questions or posts. Though not relevant here because the env file is for localhost, but still don't pots things we don't need to know.
    2. The way you have included your public_html folder by editing the index.php file is not recommended. What will happen when you update L5.2. Chances are these files will be overwritten. The right way is to edit the larave/config/view.php file and change the paths array.
    3. Do not use unsafe characters in your URLs e.g. ~obts contains the unsafe character ~. See this article for what characters are safe.
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 stata安慰剂检验作图但是真实值不出现在图上
  • ¥15 c程序不知道为什么得不到结果
  • ¥40 复杂的限制性的商函数处理
  • ¥15 程序不包含适用于入口点的静态Main方法
  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题