加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

正则表达式 – 如何在1and1共享主机上为Cake 2.3.x配置htaccess

发布时间:2020-12-14 06:03:11 所属栏目:百科 来源:网络整理
导读:对不起,我做了很多搜索,但没有找到解决问题的方法. 当我想在子文件夹中安装Cakephp应用程序时,使用默认的cakephp htaccess文件设置将无法在我的域上运行,而所有内容都适用于localhost(xampp) target = http://mydomain.com/mycakeapp 安装需要3个htaccess文
对不起,我做了很多搜索,但没有找到解决问题的方法.

当我想在子文件夹中安装Cakephp应用程序时,使用默认的cakephp htaccess文件设置将无法在我的域上运行,而所有内容都适用于localhost(xampp)

target => http://mydomain.com/mycakeapp

安装需要3个htaccess文件:

root .htaccess
????

    #.htaccess in root
    
       RewriteEngine on
       RewriteBase  /mycakeapp
       RewriteRule    ^$app/webroot/    [L]
       RewriteRule    (.) app/webroot/$1 [L]
    
    

????在应用程序.htaccess
????

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

????在webroot .htaccess中
????

        
            RewriteEngine On
            RewriteBase /mycakeapp
            RewriteCond %{REQUEST_FILENAME} !-d
            RewriteCond %{REQUEST_FILENAME} !-f
            RewriteRule ^(.*)$index.php [QSA,L]
        
    

在cakephp文档和使用这些htaccess文件之后,我得到了error500结果.
使用RewriteBase /而不是/ mycakeapp会抛出404错误页面.

php是5.4版本
我怎么解决这个问题?
非常感谢您的帮助 !
问候

解决方法

像这样设置你的规则:

DOCUMENT_ROOT中的.htaccess

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

DOCUMENT_ROOT / mycakeapp中的.htaccess

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

DOCUMENT_ROOT / mycakeapp / app中的.htaccess

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

DOCUMENT_ROOT / mycakeapp / app / webroot中的.htaccess

RewriteEngine On
RewriteBase /mycakeapp/app/webroot/

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读