Support the ongoing development of Laravel.io →
Configuration
Last updated 2 years ago.
0

Hi,

Easiest way is to create a .htaccess file in your laravel root directory, then add this into the file:

<IfModule mod_rewrite.c>
    RewriteEngine On

    RewriteRule ^(.*)$ public/$1 [L]
</IfModule>

Better option (recommended for production environments), is to set you document root for apache (xampp) to the public folder, and not the laravel folder.

Source: https://coderwall.com/p/erbaig Source2: Personal Experience

Last updated 2 years ago.
0

Change your document root in your apache config from "your/path/to/laravel" to "your/path/to/laravel/public"

Last updated 2 years ago.
0

thepsion5 said:

Change your document root in your apache config from "your/path/to/laravel" to "your/path/to/laravel/public"

AGREE

Last updated 2 years ago.
0

supernoctem said:

Hi,

Easiest way is to create a .htaccess file in your laravel root directory, then add this into the file:


   RewriteEngine On

   RewriteRule ^(.*)$ public/$1 [L]

Better option (recommended for production environments), is to set you document root for apache (xampp) to the public folder, and not the laravel folder.

Source: https://coderwall.com/p/erbaig Source2: Personal Experience

Hi! on Xamp I'm using virtual host and on my shared host I did it like this : [http://driesvints.com/blog/laravel-4-on-a-shared-host]

Last updated 2 years ago.
0

thepsion5 said:

Change your document root in your apache config from "your/path/to/laravel" to "your/path/to/laravel/public"

This is the best and most correct way to accomplish this. It is the recommended configuration from the Laraval install guide.

Last updated 2 years ago.
0

Thanks guys,

This is great on local host. On my on line server I dont have accesst o apache config.

What should I do there?

Thanks

Last updated 2 years ago.
0

So I decided to set up the virtual host. Things that I did:

/Applications/XAMPP/etc/httpd.conf

Include etc/extra/httpd-vhosts.conf    

/Applications/XAMPP/etc/extra/httpd-vhosts.conf


<VirtualHost *:80>ServerAdmin [email protected]
DocumentRoot "/Applications/XAMPP/htdocs/ben/public"
ServerName "Application/XAMPP/htdocs/ben"
ErrorLog "Application/XAMPP/htdocs/ben/error_logs_server"
</VirtualHost>

When I go to h t t p://localhost/ben I see the list of directories in that folder (including public).

I have also created the hosts file in etc and it contains


/Applications/XAMPP/htdocs/ben/public /Applications/XAMPP/htdocs/ben    

What would be the next step to fix this?

Thanks

Last updated 2 years ago.
0

Hi, I have tried this and i am also sharing way what i used for remove public from url Here

Last updated 2 years ago.
0

If you can't set the root folder on a server, you can always do something like this:

  • copy the contents on "public" into the www-root folder
  • cope the rest of the laravel files (everything except the public folder) to anywhere on the hard drive (not inside the wwwroot)
  • change the path in index.php to point to the above folder to load bootstrap.php
  • change the paths in bootstrap/paths.php to point to the www-root

That way you can use the existing document root without getting a /public/ folder (or keeping your /app folder accessible from the web), and no need to change any server settings. Disclaimer: I didn't try it myself, but it should work :)

Hope that helps.

Last updated 2 years ago.
0
Last updated 8 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.