Install Laravel 5 app in subdirectory with htaccess

后端 未结 4 1809
深忆病人
深忆病人 2020-12-16 12:14

The Setup

I am trying to install a laravel 5 app in this directory on my server:

public_html/myapp/

And I want it to be accessed at th

4条回答
  •  余生分开走
    2020-12-16 12:48

    You can easily achieve this by adding additional .htaccess file in the myapp folder (this will redirect all of your requests in myapp folder to the public as it should):

    
        RewriteEngine On
        RewriteRule ^(.*)$ public/$1 [L]
    
    

    You should also modify the .htaccess in your myapp/public directory, like this:

    
        Options -MultiViews
        RewriteEngine On    
        RewriteBase /myapp/
    
        RewriteCond %{REQUEST_FILENAME} !-d
        RewriteCond %{REQUEST_FILENAME} !-f
        RewriteRule . index.php [L]
    
    

    The change here is that you rewrite the base path RewriteBase /myapp/

提交回复
热议问题