0

I am running the latest version of laravel on my own server running Debian and Apache2.

The contents of laravel are located in /var/www which is what my domain name is pointed to however all of the functionality happens through the public directory so I would have to go to http://mydomain.com/public to access anything.

I would like to change it so that I only have to access http://mydomain.com. Is this possible?

How can I change this? Would I have to move everything up another level to the parent at /var?

I haven't found anything online so far that says that it is possible, or that it is a good idea.

Michael
  • 4,282
  • 9
  • 55
  • 89
  • 1
    Check this... http://stackoverflow.com/a/12827445/388382 – kanenas Dec 12 '13 at 15:50
  • Yep, the link kanenas.net posted has the two answers: 1) Re-direct your virtual host, and 2) if you absolutely can't, there's an .htaccess you can place in your root folder. – Matt Stauffer Dec 12 '13 at 16:02

5 Answers5

5

That is not your problem, you need to point the virtual host to the public folder.

wesside
  • 5,622
  • 5
  • 30
  • 35
  • I am using other subdirectories on the domain too... Or, is that possible through larval? Or... Am I going about it the wrong way? – Michael Dec 12 '13 at 15:48
  • 2
    You should really modify your server setup instead of the code base. Add those subdirectories to the public folder and point the vhost to /var/www/public – wesside Dec 12 '13 at 15:50
  • Thank you. I have done that and it works. Is there no harm in putting extra directories within the larval public directory then? – Michael Dec 12 '13 at 15:59
  • Not as long as you want to those files to be publicly accessible. – wesside Dec 12 '13 at 16:01
  • Virtual host is a good solution but virtual host is not always available in a shared hosting server even though the questioner did not mention about that. – kta Mar 23 '14 at 09:20
  • Try **My Solution** It will work **everywhere**. check Link https://stackoverflow.com/questions/25222509/laravel-not-detecting-files-from-public-folder/69517681#69517681 – pankaj Oct 10 '21 at 18:04
2

Add a file in laravel root directory, name it as .htaccess and put this inside,

<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
    Options -MultiViews
</IfModule>

RewriteEngine On

RewriteCond %{REQUEST_FILENAME} -d [OR]
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^ ^$1 [N]

RewriteCond %{REQUEST_URI} (\.\w+$) [NC]
RewriteRule ^(.*)$ public/$1 

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ server.php

It will be fixed surely.

Imad Ullah
  • 929
  • 9
  • 17
0

The following worked for me, as discussed here: https://stackoverflow.com/a/16569078/3091980

Move all contents of the /public folder down a level. Then update the include lines in index.php to point to the correct location - if it's down a level, remove the "../".

Community
  • 1
  • 1
Bryan T
  • 26
  • 4
0

Sorry I deleted my old answer .. that was if u rename server.php to index then it will work but of course not because laarvel not load all service. so you have to paste into root all public folder file. and remove "../" from everywhere in index.php

pankaj
  • 1
  • 17
  • 36
0

Locate your httpd.conf and change the part that DocumentRoot "/var/www" to "/var/www/public" and override directory to allow .htaccess file of laravel

...
DocumentRoot "/var/www/public"
...
<Directory "/var/www/public">
   AllowOverride None
   Options None
   Order allow,deny
   Allow from all
</Directory>

...

Pascal Tovohery
  • 888
  • 7
  • 19