Reputation: 1283
i am very new to laravel. i've tried following solution to remove '.public/index.php' from Laravel url.
i have one htaccess file on root and other in public folder.
in root file i've written
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_URI} !^public
RewriteRule ^(.*)$ public/$1 [L]
</IfModule>
and in public folder's htaccess file i wrote
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
RewriteEngine On
# Redirect Trailing Slashes...
RewriteRule ^(.*)/$ /$1 [L,R=301]
# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>
but nothing worked.
still it opens list of directories in laravel
all i want is to convert my url www.abc.com/public/index.php
into www.abc.com/
without removing files from public folder to some other folder type solution.
Upvotes: 1
Views: 1533
Reputation: 73211
You simply need to fix your Document root and the Directory override rule within your sites .conf
file.
On Ubuntu you will find this in /etc/apache2/sites-available
Your file should look something like this:
<VirtualHost *:80>
ServerName xxx.com
ServerAlias www.xxx.com
ServerAdmin [email protected]
DocumentRoot /var/www/html/laravel/public/ //<<< add public to your document root
<Directory "/var/www/html/laravel/public"> ## <<< add the override rule if not exists
AllowOverride all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
Your laravel app should not be in the document root in any case, as you would allow anybody to access it!
SIDENOTE:
If you are using plesk or c-panel, you can edit the document root within the domain settings.
Upvotes: 1
Reputation: 31
In your Apache configuration, set the document root to /yourapp/public
-- this is meant to be the root web accessible folder; you're opening yourself up to access you may not want if the webroot is anything other than Laravel's public
folder.
Upvotes: 0