You are not logged in.

Important Note: This forum is being archived and will be completely locked down on the 7th of February. The new forum can be found at http://laravel.io.

Announcement

    Laravel 4 Advanced Architecture: Book Now On Sale

#1 2012-05-25 10:19:58

ShawnMcCool
Quality Team
From: Utrecht, Netherlands
Registered: 2011-10-05
Posts: 535
Website

Understanding the Laravel PUBLIC folder

This guide tells you how to host Laravel without requiring that the hosting environment allows you to change your document root path to your public folder.

There may be reasons why you cannot or choose not to change your web server's DocumentRoot configuration. Below are some other options.


Note: I tend to speak in hyperbole.

About Shawn McCool | About Big Name | BigTo.Do - FreshBooks time tracking for to-dos | Laravel IO - The Official Laravel Community Portal

Offline

#2 2012-06-25 12:27:49

ShawnMcCool
Quality Team
From: Utrecht, Netherlands
Registered: 2011-10-05
Posts: 535
Website

Re: Understanding the Laravel PUBLIC folder

Solution 1 - Alternate installation path with symlink.

This is the preferred solution and in general an all-around good idea. It's possible to install your application to a folder unrelated to public_html/ and then symlink the public folder to the public_html/ path.

For example:

Install your application to /home/applications/mysite.com

Imagine that your DocumentRoot points to /var/www/vhosts/mysite.com/httpdocs

Remove the httpdocs folder from the mysite.com vhosts folder then connect the two with a symlink: ln -s /home/applications/mysite.com/public /var/www/vhosts/mysite.com/httpdocs

Voila, clean as can be.


Note: I tend to speak in hyperbole.

About Shawn McCool | About Big Name | BigTo.Do - FreshBooks time tracking for to-dos | Laravel IO - The Official Laravel Community Portal

Offline

#3 2012-06-25 12:33:35

ShawnMcCool
Quality Team
From: Utrecht, Netherlands
Registered: 2011-10-05
Posts: 535
Website

Re: Understanding the Laravel PUBLIC folder

Solution 2 - .htaccess with mod_rewrite

This solution enables you to drop Laravel into your public folder then use a .htaccess file to redirect requests to the public folder. This solution places your application and core system code into a publicly accessible folder. This is not something that we encourage you to do with any PHP framework.

Step 1. Place Laravel in your document root folder.

Step 2. Place the following .htaccess file in your document root folder.

<IfModule mod_rewrite.c>
    RewriteEngine on
    RewriteCond %{REQUEST_URI} !^public
    RewriteRule ^(.*)$ public/$1 [L]
</IfModule>

Step 3. Make sure that you manually set your 'url' configuration in application/config/application.php otherwise Laravel will generate incorrect URLs. Make sure that each of your environments have the correct application.url configuration. For more information on environment-specific configurations see: http://laravel.com/docs/install#environments

That's all.


Note: I tend to speak in hyperbole.

About Shawn McCool | About Big Name | BigTo.Do - FreshBooks time tracking for to-dos | Laravel IO - The Official Laravel Community Portal

Offline

#4 2012-07-02 09:53:40

ShawnMcCool
Quality Team
From: Utrecht, Netherlands
Registered: 2011-10-05
Posts: 535
Website

Re: Understanding the Laravel PUBLIC folder

Solution 3 - merge the public folder into the installation root

This solution places your application and core system code into a publicly accessible folder. This is not something that we encourage you to do with any PHP framework.

Copy the contents of the public/ folder into your Laravel installation folder then change this line in your index.php file from:

    require '../paths.php';

to

    require 'paths.php';

Keep in mind that any bundles, libraries, or other types of third-party code may not be designed to be publicly accessible.

Note: It's also important to note that your bundles/ and public/bundles/ directories will now conflict. When using this approach you may want to not use artisan's bundle:publish task without knowing exactly what your bundles want to publish.


Note: I tend to speak in hyperbole.

About Shawn McCool | About Big Name | BigTo.Do - FreshBooks time tracking for to-dos | Laravel IO - The Official Laravel Community Portal

Offline

#5 2013-07-29 15:14:11

krishna.soni
Apprentice
From: India
Registered: 2013-07-29
Posts: 1

Re: Understanding the Laravel PUBLIC folder

Hello All,

I am new for PHP and laravel. I installed eclipse for PHP and now want to add laravel 3.0 on this IDE.
How can I do this?
Please help..

Offline

#6 2013-07-29 20:11:40

AndrewB
Artisan
From: New Zealand
Registered: 2012-05-29
Posts: 660

Re: Understanding the Laravel PUBLIC folder

krishna.soni wrote:

Hello All,

I am new for PHP and laravel. I installed eclipse for PHP and now want to add laravel 3.0 on this IDE.
How can I do this?
Please help..

Laravel 4 is the current version, why do you want L3?

Offline

#7 2013-09-07 10:40:48

zaher
Apprentice
From: Dirkey
Registered: 2012-09-17
Posts: 1

Re: Understanding the Laravel PUBLIC folder

Do we have the same issue in L4?

Offline

#8 2013-11-03 11:14:43

aldikun1
Artisan
Registered: 2013-09-11
Posts: 13

Re: Understanding the Laravel PUBLIC folder

ShawnMcCool wrote:

Solution 1 - Alternate installation path with symlink.

This is the preferred solution and in general an all-around good idea. It's possible to install your application to a folder unrelated to public_html/ and then symlink the public folder to the public_html/ path.

For example:

Install your application to /home/applications/mysite.com

Imagine that your DocumentRoot points to /var/www/vhosts/mysite.com/httpdocs

Remove the httpdocs folder from the mysite.com vhosts folder then connect the two with a symlink: ln -s /home/applications/mysite.com/public /var/www/vhosts/mysite.com/httpdocs

Voila, clean as can be.

i upload my application in home/manilagov/vehicles
outside the public_html or htdocs it said i need to link the/public to public html
all i need to do now is

Imagine that your DocumentRoot points to /var/www/vhosts/mysite.com/httpdocs

Remove the httpdocs folder from the mysite.com vhosts folder then connect the two with a symlink: ln -s /home/applications/mysite.com/public /var/www/vhosts/mysite.com/httpdocs

where should i put this. So i can migrate to L4.

thanks for this post helps alot

Offline

#9 2014-01-20 08:56:37

datavirtue
Artisan
From: Cincinnati Ohio
Registered: 2014-01-15
Posts: 7

Re: Understanding the Laravel PUBLIC folder

After staring at server configs and regex for hours (really days) I whip up a simple little symlink and everything works perfect.  I'm taking a nap now.

Offline

Board footer

Powered by FluxBB

');