wpcpremium80
wpcpremium80

Reputation: 98

Laravel on Apache - wrong URLs

I have deployed Laravel on Apache server, but got problem with wrong URLs.

The app directory is /var/www/laravel, but I only get access on it at:

http://127.0.0.1/laravel/public/index.php

On URL http://127.0.0.1/laravel I see tree of project files, on http://127.0.0.1/laravel/public I get message

Not Found
The requested URL was not found on this server.

What I want to achieve is to get access via http://127.0.0.1/laravel to my app.

.htaccess file:

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

    RewriteEngine On

    # Handle Authorization Header
    RewriteCond %{HTTP:Authorization} .
    RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]

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

    # Send Requests To Front Controller...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^ index.php [L]
</IfModule>

/etc/httpd/conf/httpd.conf v-host configuration:

<VirtualHost 127.0.0.1/laravel:80>
        ServerName 127.0.0.1
        ServerAlias localhost
        DocumentRoot /var/www/laravel/public
        <Directory /var/www/laravel/public>
                Options Indexes FollowSymLinks
                AllowOverride All
                Require all granted
        </Directory>
</VirtualHost>

What I want mention is that I use CentOS 8 and I want to host more that 1 project on it.

What I do wrong?

Upvotes: 0

Views: 265

Answers (1)

mister_cool_beans
mister_cool_beans

Reputation: 1533

This will listen for any IP address on port 80 including local host IP 127.0.0.1. Set up a different virtual host for access by domain name instead of IP address.

<VirtualHost *:80>

        DocumentRoot /var/www/main

        <Directory /var/www/main>

                Options Indexes FollowSymLinks
                AllowOverride All
                Require all granted

        </Directory>

</VirtualHost>

Upvotes: 1

Related Questions