1. I understand why you are trying to change .htaccess, but this can be solved much easier. Revert .htaccess file to Laravel standard
<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] </IfModule>
2. Move all your folders and files separately from the public ones and make sure that they are located behind your HTML folder.
3. Move all your shared folders and files from the shared folder and to your html folder
4. Tell laravel to look in your html folder instead of public by changing the server.php file
<?php /** * Laravel - A PHP Framework For Web Artisans * * @package Laravel * @author Taylor Otwell < taylorotwell@gmail.com > */ $uri = urldecode( parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH) ); // This file allows us to emulate Apache "mod_rewrite" functionality from the // built-in PHP web server. This provides a convenient way to test a Laravel // application without having installed a "real" web server software here. if ($uri !== '/' && file_exists(__DIR__.'/html'.$uri)) { return false; } require_once __DIR__.'/html/index.php';
I find this solution much easier than htaccess talking to you. You also warrant that all major Laravel files cannot be accessed from the URL.
Another problem you are facing (inner pages)
This is probably due to the fact that your apache does not allow overriding with Laravels htaccess
Go to the command line of your server and get access to the apache2.conf file
cd /etc/apache2
Open apache2.conf file with nano
sudo nano apache2.conf
Now find the following
<Directory /var/www/> Options Indexes FollowSymLinks AllowOverride None Require all granted </Directory>
Change it to
<Directory /var/www/> Options Indexes FollowSymLinks AllowOverride All Require all granted </Directory>
Record the changes and exit nano.
Restart apache
sudo service apache2 restart
Now it should work :)
Chris townsend
source share