Laravel作为现有网站的插件

I have my site already built up in say: http://example.com My Directory structure is:

root/
  |
  -- htdocs/    ---> This is the document root. All the front end scripts are located here.
  |  |
  |  - css/
  |  - ...
  |
  -- cms/   --> This is the backend. This site is like a cms Driven Site.

Now I wanted to install laravel in the back end. I want to build my CMS using laravel. But I don't want the URL to be like: http://example.com/cms/public/

I want it just to be: http://example.com/cms/

I know, I can just place all the folders outside in the document root and rename the public folder and change some settings to achieve what I want. But I don't want my document root to have all those files & folders and files mixed with my front end related files & folders. I want this whole thing to be separate and easy to use in other web site back end.

In order to achieve this, I have used 2 .htaccess files.

In the document root, I have:

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

And inside the cms folder I have:

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

I am not very good at writing .htaccess or doing mod_rewrite.

Can anybody help me

You could achieve what you want in this way:

Create a directory junction for the public folder from laravel to your backend target folder:

mklink /J C:\www\htdocs\app-frontend\cms C:\www\htdocs\app-backend\public

The first path is for the alias and the second path is for the real folder. Here app-backend would be the folder where laravel is installed to.

This is how I deal with Laravel in shared hosting.

If you were to opt for the mod_rewrite approach, the .env file will be exposed.