简体   繁体   中英

Configure server to open public/index.php on '/' Laravel Project

I'm currently working on deploying a laravel project for the first time. I have succeeded in installing a laravel project on my server but unfortunately, when going to the website no laravel page is shown. My .htaccess file in the root directory:

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

    RewriteEngine On

    # Redirect Trailing Slashes If Not A Folder...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)/$ /$1 [L,R=301]

    # Handle Front Controller...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^ index.php [L]

    RewriteEngine On
    RewriteCond %{HTTP_HOST} ^(www.)?mydomain.nl$
    RewriteRule ^(/)?$ public [L]
</IfModule>

Could someone please help me with this issue?

We do not know about what kind of server this is and where you got it (AWS, Digital Ocean).

Generally you have to move to this directory in your server:

/etc/apache2/sites-enabled/laravel.conf

Now you open that file using the touch, vi or nano:

sudo nano laravel.conf

The file should have a similiar content to this one:

<VirtualHost *:80>.
    ServerName app.com // your server name
    ServerAdmin webmaster@localhost
    # Your Custom folder 
    DocumentRoot /dir/dir/dir/app/public/ // here you need to add your location
    <Directory /dir/dir/dir/app/public/>  // here you need to add your location
    Options Indexes FollowSymLinks
    AllowOverride None
    Require all granted
</Directory>
    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log
</VirtualHost>

Now you need to change to location to your app/public location like I did in the sample config file.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM