Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.1k views
in Technique[技术] by (71.8m points)

.htaccess - Laravel Routes not working, Apache configuration only allows for public/index.php/route

Example:

Route::get('/get', function() {
    return 'get';
});

To view the route above, I must navigate to public/index.php/get.

I've viewed quite a few SO posts and googled around trying different things and it hasn't made a difference (yes I restart apache every time).

Here is my .htaccess in the public directory:

<IfModule mod_rewrite.c>
    Options +FollowSymLinks
    RewriteEngine On
</IfModule>

# For all files not found in the file system, reroute the request to the
# "index.php" front controller, keeping the query string intact

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>

What could be causing this still? I'm running Ubuntu.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Two most common causes of this behavior are:

  1. mod_rewrite not enabled

    sudo a2enmod rewrite && sudo service apache2 restart

  2. AllowOverride is set to None, set it to All, assuming Apache2.4

    sudo nano /etc/apache2/apache2.conf

search for <Directory /var/www/> and change AllowOverride None to AllowOverride All, then save the file and restart apache


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...