I am working on my local server right now and trying to get rid of '/public/index.php' from http://localhost/example/public/index.php/ in the url. I have followed content from the site: https://www.tutsmake.com/how-to-remove-public-from-url-in-laravel/ and added the config file laravelex.conf with the following content:
<VirtualHost *:80>
ServerName localhost
ServerAdmin webmaster@localhost
DocumentRoot /var/www/example/public
<Directory /var/www/example>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
Require all granted
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
In my project, uder the public folder I have .htaccess file as follows:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^(.*)$ public/$1 [L]
</IfModule>
But when I'm trying to open http://localhost/laravel_project_folder/ or even http://localhost/laravel_project_folder/index.php/ I'm getting Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.
Please contact the server administrator at webmaster@localhost to inform them of the time this error occurred, and the actions you performed just before this error.
More information about this error may be available in the server error log.
Apache/2.4.29 (Ubuntu) Server at localhost Port 80
The error in the log file is
AH00124: Request exceeded the limit of 10 internal redirects due to probable configuration error. Use 'LimitInternalRecursion' to increase the limit if necessary. Use 'LogLevel debug' to get a backtrace.
Note: I have also tried to change .htaccess in the following way by looking at the answer by @stephen:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php?url=$1 [QSA,L]
</IfModule>
change the file structure like this:
copy all of the project files to the core folder and copy the content of the public folder to the main folder.
then fix path of
autoload.php
andapp.php
inindex.php
: