1

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.

1
  • @RakeshSharma i mentioned in my question 'not the folder change solution..' :) Commented Dec 3, 2014 at 6:50

2 Answers 2

1

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.

Sign up to request clarification or add additional context in comments.

Comments

0

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.