dsfdgdsfd23212 2015-10-31 13:37
浏览 26
已采纳

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

  • 写回答

1条回答 默认 最新

  • douchen7324 2015-10-31 17:45
    关注

    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.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥100 连续两帧图像高速减法
  • ¥15 组策略中的计算机配置策略无法下发
  • ¥15 如何绘制动力学系统的相图
  • ¥15 对接wps接口实现获取元数据
  • ¥20 给自己本科IT专业毕业的妹m找个实习工作
  • ¥15 用友U8:向一个无法连接的网络尝试了一个套接字操作,如何解决?
  • ¥30 我的代码按理说完成了模型的搭建、训练、验证测试等工作(标签-网络|关键词-变化检测)
  • ¥50 mac mini外接显示器 画质字体模糊
  • ¥15 TLS1.2协议通信解密
  • ¥40 图书信息管理系统程序编写