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

问题描述:

我在共享主机的根目录"public_html"中安装了laravel应用,现在我想在ru/子文件夹中安装该应用的俄语版本,但是当我转到example.com/ru时,出现404 Page not found错误.我使用apache Web服务器,我在根文件夹中的.htaccess文件包含以下代码

I install laravel app in root of my shared host "public_html now I want to install Russian version of this app in ru/ subfolder but when I go to example.com/ru I got 404 Page not found error. I use apache web server my .htaccess file in root folder contain these code

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

我应该如何更改此配置?

how should i change this configuration?

谢谢.

您将按照在根目录中安装它的相同方式进行操作.我将告诉您如何将其安装在共享托管帐户(主域和子域)上.将所有项目上传到子文件夹后,您将成为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>