简体   繁体   中英

How to remove 'public' from Laravel URL hosted on child folder?

I have a Laravel 5.3 project on shared hosting located at the following address .

How to remove the public from URL?

Now the same question was asked at Remove public from URL Laravel 5.3 on shared hosting but many answers were asking to move all public content to root domain, but my root domain is already hosting something with index.php in it.

Can you please tell me how to do it? All other information is same as the question shared, ie default .htaccess file in public as well as home (laravel installation) folder. Second I am in shared hosting, I cant change Vhost or something.

Here is my folder structure inside https://yourdomain.tld/home folder

在此处输入图片说明

I think there are 3 possible solutions:

  1. Since you use vhost instead of localhost, the problem might be the DocumentRoot declaration. I use Xampp, so the path and code will be based on that. In my case, the file that creates vhost is located:
C:\Xampp\apache\conf\extra\httpd-vhosts.conf

The vhost code is this:

<VirtualHost *:80>
    DocumentRoot "C:/Xampp/htdocs/mydomain/home/public"
    ServerName mydomain.tld/home
    ErrorLog "logs/mydomain-e1rror.log"
    CustomLog "logs/mydomain-access.log" common
</VirtualHost>

BTW, make sure you 127.0.0.1 mydomain.tld in "etc" file if you use a Windows machine.

When you enter www.mydomain.tld it should hit the index.php file that is located in public folder.

  1. Since you use very old version of Laravel, I suppose you download it from liveserver. When we deploy our app, we make some changes in public/index.php file to tell our app where Laravel is. Look for
require __DIR__.'/../vendor/autoload.php'; //

I think this is different in your index.php file. BTW, I don't know if this path is different in version 5.3.

  1. Your folder structure is incorrect. You might try to compare it with freshly installed Laravel.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM