The root directory of the space is dead, but the index of Laravel must be put public, how to do

Source: Internet
Author: User
Keywords laravel-5 laravel5 php website website program
Tags autoload
Bought a 50 block a year of space, support PHP, but the root directory is set to die for www, that is to say index.html index.php must put here, but Laravel framework index.php must be put in public inside, how should I do?

Reply content:

Bought a 50 block a year of space, support PHP, but the root directory is set to die for www, that is to say index.html index.php must put here, but Laravel framework index.php must be put in public inside, how should I do?

LaravelSuch a good frame is really not suitable for virtual hosting, really recommend the purchase of ECS products.

There are, of course, some solutions:
1. First put the ./public directory down, .htaccess move it index.php favicon.ico outside
(with app , bootstrap , public , folder on the vendor same layer)
2. Modificationsindex.php

require __DIR__.'/../bootstrap/autoload.php';$app = require_once __DIR__.'/../bootstrap/start.php';//改成以下require __DIR__.'/bootstrap/autoload.php';$app = require_once __DIR__.'/bootstrap/start.php';

done!

This should be able to change, although I have not tried ha. In fact, the directory you can use on the server is
/root directory
/www Web Directory
You can use WWW as public, and then the other source in the root directory can be, in adjusting the settings, feel the problem is not very large. I use this experience, however, the previous version has bootstrap/paths.php, which has
' Public ' = __dir__. ' /.. /public ',
Just change it, okay?

Another is to look at the documentation provided by your service provider, is it possible to customize some settings, and some hosts allow users to extend Apache configuration files and custom php.ini.

The practice of placing publicly accessible resources under public is to protect other sources from accidental access, so it is not recommended to set the common and normal source to the same directory.

Do a soft connection to map www to public can?

In fact, there is a very simple way, you can rename the root directory of the server.php to index.php No.
When you visit, you http://XXX.com/index.php/your route.

Using Nginx
Modify Configuration
server {

    listen       80 default_server;    server_name  www.my_job.com;    root www/my_job/public;

}

Outside index.php introduced public/index.php do not know the line, not used LA

This simple ah, virtual Cloud Host server should be open rewrite module, write a rewrite on the line, do not need to change any laravel source code

  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.