且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在共享主机的子文件夹中安装laravel应用程序?

更新时间:2022-11-04 20:41:39

您将按照在根目录中安装它的相同方式进行操作.我将告诉您如何将其安装在共享托管帐户(主域和子域)上.将所有项目上传到子文件夹后,您将成为example.com/ru,请执行以下操作:

You will do it in the same way you installed it in the root directory. I will tell you how I installed it on my shared hosting account, both main and sub domains. After I uploaded all my project to the subfolder, and your will be example.com/ru, do the following:

  1. 您的公用文件夹中有您的.htaccess文件.由于您基本上是将其作为子域,因此它必须位于该子域的根目录中,因此请将.htaccess从公用文件夹传输到ru文件夹的根目录.
  2. 打开.htaccess并更改/添加以下内容:

  1. In your public folder there is your .htaccess file. since you are basically making this a subdomain, it will need to be in the root of that subdomain, so transfer the .htaccess from public folder to the root of ru folder.
  2. Open the .htaccess and change/add the following:

DirectoryIndex public/index.php

,然后在RewriteRule中将其更改为此:

and in the RewriteRule change it to this:

public/index.php

请注意,更改后的.htaccess应该像这样:

And just to be clear, your .htaccess should be like this at the end after your changes:

DirectoryIndex public/index.php
<IfModule mod_rewrite.c>
    <IfModule mod_negotiation.c>
        Options -MultiViews
    </IfModule>

    RewriteEngine On

    # Redirect Trailing Slashes If Not A Folder...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)/$ /$1 [L,R=301]

    # Handle Front Controller...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^ public/index.php [L]

    # Handle Authorization Header
    RewriteCond %{HTTP:Authorization} .
    RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
</IfModule>