How to install laravel app in subfolder of shared host?

旧城冷巷雨未停 提交于 2020-01-14 14:10:40

问题


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?

Thanks.


回答1:


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. 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
    

    and in the RewriteRule change it to this:

    public/index.php
    

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>


来源:https://stackoverflow.com/questions/41407758/how-to-install-laravel-app-in-subfolder-of-shared-host

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!