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 微信小程序协议怎么写
  • ¥15 c语言怎么用printf(“\b \b”)与getch()实现黑框里写入与删除?
  • ¥20 怎么用dlib库的算法识别小麦病虫害
  • ¥15 华为ensp模拟器中S5700交换机在配置过程中老是反复重启
  • ¥15 java写代码遇到问题,求帮助
  • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看