1

I just made a simple laravel application in CentOS running in apache server. The thing is I always gets an error:

"Not Found" when redirecting to other pages.

How do I fix this ? I'am completely new on using CentOS and apache server.

Note: It is working fine with Windows and xampp.

Here is my .htaccess file

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]

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

2 Answers2

0

It's likely that you don't have Apache set up to properly rewrite your route and hand it to the index.php file. Have a look at the Apache section near the bottom of this page and ensure that your redirects mirror what this page lays out.

Michael Miller
  • 369
  • 1
  • 9
0

Try that route with index.php? like yourdomain.com/index.php/route-url and check if it works. If your homepage works and other pages do not, then your rewrite rule is no set.

  • Do
sudo a2enmod rewrite on 

your server terminal and then restart apache

  • In Apache virtual host section add
AllowOverride all

And in your laravel's .htaccess add this :

Options +FollowSymLinks -Indexes
RewriteEngine On

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

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
Mihir Bhende
  • 6,876
  • 1
  • 15
  • 30