Why and How to resolve the /public folder in the link?

1. How can remove "public" from url?

2. When people are clicking on my indexed pages through Google Search Engine It is taking the user to /public

We are using Laravel framework. As you know, its directory looks like this:

To open the homepage of my website (Route::get('/', '[email protected]');) I need to open /public folder of directory. In another word, to see the first page of my website here is the URL:

http://example.com/public

To resolve these issues, we did create a .htaccess file:

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

But when people are clicking on my indexed pages through Google Search Engine It is taking the user to /public. 

Follow Laravel framework Guideline, You have to change the root directory to the public folder to avoid security. In Cpanel, you can do it, but some hosting provider does not allow you to change for Primary domain. So, there are 3 solutions for you:

1. You need to contact your hosting provider to change the root directory of your primary domain to /public_html/pubic (now its /public_html)

2. You can change domain as add-on domain of your hosting package (because we can help you change for add-on domain easily)

3. You can move to another hosting provider that allows change root directory of the primary domain

 

Was this article helpful?

You voted : No

Related Articles