Frank Barcenas Frank Barcenas - 5 months ago 30
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
</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]

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


My vhost is the following:

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

Answer

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
</Directory>

change the directory path as per yours.