2

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.

2
  • 1
    Check this... stackoverflow.com/a/12827445/388382 Commented Dec 12, 2013 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. Commented Dec 12, 2013 at 16:02

5 Answers 5

5

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

Sign up to request clarification or add additional context in comments.

6 Comments

I am using other subdirectories on the domain too... Or, is that possible through larval? Or... Am I going about it the wrong way?
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
Thank you. I have done that and it works. Is there no harm in putting extra directories within the larval public directory then?
Not as long as you want to those files to be publicly accessible.
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.
|
3

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.

Comments

1

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 "../".

Comments

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

Comments

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>

...

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.