douwo5710 2013-12-09 13:43
浏览 76
已采纳

从网址中删除app / webroot

I'm trying to remove app/webroot from the url in my CakePHP application using htaccess. We know it can be fixed just by pointing the vhost to the app/webroot folder, but for some reasons the developers over here prefer to fix this using htaccess.

Anyone who knows or this is possible?

  • 写回答

1条回答 默认 最新

  • duanpacan2583 2013-12-09 13:54
    关注

    Setup your various .htaccess like this:

    .htaccess in DOCUMENT_ROOT:

    RewriteEngine on
    RewriteBase /
    RewriteRule (.*) app/webroot/$1 [L]
    

    .htaccess in DOCUMENT_ROOT/app

    RewriteEngine on
    RewriteBase /app/
    RewriteRule (.*) webroot/$1 [L]
    

    .htaccess in DOCUMENT_ROOT/app/webroot

    RewriteEngine On
    RewriteBase /app/webroot/
    
    RewriteCond %{THE_REQUEST} \s/+app/webroot/([^\s&]*) [NC]
    RewriteRule ^ /%1 [R=302,L]
    
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^ index.php [L]
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 微信会员卡接入微信支付商户号收款
  • ¥15 如何获取烟草零售终端数据
  • ¥15 数学建模招标中位数问题
  • ¥15 phython路径名过长报错 不知道什么问题
  • ¥15 深度学习中模型转换该怎么实现
  • ¥15 HLs设计手写数字识别程序编译通不过
  • ¥15 Stata外部命令安装问题求帮助!
  • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
  • ¥15 TYPCE母转母,插入认方向
  • ¥15 如何用python向钉钉机器人发送可以放大的图片?