I
I
Ivan Vorobei2016-04-07 21:46:39
Apache HTTP Server
Ivan Vorobei, 2016-04-07 21:46:39

How to get rid of public/index.php in Laravel URL?

Allocated a separate api.example.com domain for all requests. At the root are project folders, one of them decided to try writing in Laravel.
The structure looks like this:

api.example.com
   project_1
   project_2

The request should look like this:
api.example.com/project/
And looks
api.example.com/project/public/index.php/
Out of the box does not work. I tried through htaccess (didn't work), and also renamed server.php according to the tutorials. All declared routes work, except for the simplest one:
api.example.com/project/
It throws a 403 error. And welcom view Laravel should present.
But everything is fine here:
api.example.com/project/public/index.php
There should be a beautiful-elegant solution, everything looks like a crutch for now. What do you advise?

Answer the question

In order to leave comments, you need to log in

4 answer(s)
I
Ivan Vorobei, 2016-04-07
@ivanvorobei

Thanks for the answers, the solution was to start via server.php in the root of the project.

D
D', 2016-04-07
@Denormalization

To get rid of public/index.php, you need to direct the DocumentRoot to the public/ folder (obviously).
If for some reason you do not want to change the DocumentRoot, then you can do the following:
- Move the project1, project2 folders FOR DocumentRoot (generally a stupid idea to put the project code in the DocumentRoot)
- Make symlinks from /path/to/project2/public to DocumentRoot/ project2
- In app.php, write the correct path to the site so that laravel correctly generates the url
- ???
- Rejoice in success.

A
Alexey Ukolov, 2016-04-07
@alexey-m-ukolov

What do you advise?
It's ok to set up a web server.
Since you did not attach your configuration, this is all that can be advised.

R
root09, 2016-04-07
@root09

.htaccess to site root

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

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question