Frank Barcenas Frank Barcenas - 1 year ago 83
PHP Question

My Laravel routes are only visible through index.php

I've checked to make sure I have mod_rewrite enabled an restarted my webserver. My .htaccess seems fine. What am I missing?

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

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]

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

My vhost is the following:

<VirtualHost *:80>
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html/cms/public
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined

Answer Source

You've created a .htaccess file, but actually didn't tell your virtual host to "Allow" .htaccess to override configuration. In other words you've not enabled htaccess suppport. Add following to your VirtualHost block to enable it:

<Directory "/var/www">
    AllowOverride All

change the directory path as per yours.