19

I have this structure:

My domain: www.example.com

and this is my laravel's project folder: http://www.example.com/project

and I would like to redirect to http://www.example.com/project/public

I know this answer has been answered before but I try to implement it and not work for me.

Sorry for my english, I just speak spanish

Andres Ruales
  • 381
  • 1
  • 2
  • 12

3 Answers3

25

For htaccess

RewriteEngine on
RewriteCond %{HTTP_HOST} ^example.com$ [NC,OR]
RewriteCond %{HTTP_HOST} ^www.example.com$
RewriteCond %{REQUEST_URI} !project/public/
RewriteRule (.*) /project/public/$1 [L]

Put it into your public_html/ or www/ folder where is the root of example.com/

Germanaz0
  • 874
  • 8
  • 18
  • 1
    Somehow this doesn't work with localhost as URL. (The 3rd line is the issue I believe, not sure why) – Ben Fransen Dec 14 '15 at 22:12
  • As @BenFransen said above this didn't work for me in localhost. Just changed to the dev linux machine hostname and it's working fine now. – cdsaenz Oct 11 '20 at 03:06
9

rename /server.php to index.php

Basem Olimy
  • 667
  • 7
  • 9
  • 3
    This works, BUT you have to edit all the the paths to CSS and JS files. Less practical than the .htaccess solution. – Nebster Jul 03 '17 at 10:23
0

I created this php script and placed in the in the root of the laravel directory:


    $actual_link = "http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";
    header("Location: " . $actual_link . "public/index.php");

Erhnam
  • 771
  • 2
  • 10
  • 22