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 删除虚拟显示器驱动 删除所有 Xorg 配置文件 删除显示器缓存文件 重启系统 可是依旧无法退出虚拟显示器
  • ¥15 vscode程序一直报同样的错,如何解决?
  • ¥15 关于使用unity中遇到的问题
  • ¥15 开放世界如何写线性关卡的用例(类似原神)
  • ¥15 关于并联谐振电磁感应加热
  • ¥60 请查询全国几个煤炭大省近十年的煤炭铁路及公路的货物周转量
  • ¥15 请帮我看看我这道c语言题到底漏了哪种情况吧!
  • ¥66 如何制作支付宝扫码跳转到发红包界面
  • ¥15 pnpm 下载element-plus
  • ¥15 解决编写PyDracula时遇到的问题