superkytoz
superkytoz

Reputation: 1279

Trying to remove public from url Laravel

I have this code in my .htaccess file:

<IfModule mod_rewrite.c>
   RewriteEngine On 
   RewriteRule ^(.*)$ public/$1 [L]
</IfModule>

But it didn't work as you can see in the screenshot below:

Link to screenshot: https://i.sstatic.net/Cox4x.png

However if I change my .htaccess file to:

Options +FollowSymLinks
RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]

Then I can see this on my browser:

Link to screenshot: https://i.sstatic.net/n8eMv.png

This is how my folder structure looks like:

Link to screenshot: https://i.sstatic.net/DDZA0.png

What have I tried?

I have already enabled my mod_rewrite in XAMPP to try to fix my solution. I had followed these steps in the link below:

Link: http://www.leonardaustin.com/blog/technical/enable-mod_rewrite-in-xampp/

Upvotes: 0

Views: 76

Answers (2)

Kevin Schenkers
Kevin Schenkers

Reputation: 116

In your vhost you should make the domains documentroot point to the /public folder.

DocumentRoot "/home/vhostsfolder/laravelproject/public"

instead of

DocumentRoot "/home/vhostsfolder/laravelproject"

What server are you using? Local/sharedhosting/vps ?

Upvotes: 0

ciruvan
ciruvan

Reputation: 5213

All you need to do is point the home directory of your site config in Apache to the public folder of your Laravel installation. Currently, it seems to point to its root folder.

Upvotes: 1

Related Questions