如何在 1and1 共​​享主机上为 Cake 2.3.x 配置 htaccess 文件 [英] How to configure htaccess file for Cake 2.3.x on 1and1 shared hosting

查看:11
本文介绍了如何在 1and1 共​​享主机上为 Cake 2.3.x 配置 htaccess 文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我想在子文件夹中安装我的 Cakephp 应用程序时,使用默认的 cakephp htaccess 文件设置在我的域上不起作用,而一切都在 localhost (xampp) 上运行

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

安装需要 3 个 htaccess 文件:

root .htaccess<前>#.htaccess 根目录重写引擎开启RewriteBase/mycakeapp重写规则 ^$ app/webroot/[L]RewriteRule (.) app/webroot/$1 [L]

在应用 .htaccess 中<前>重写引擎开启RewriteBase/mycakeapp重写规则 ^$ app/webroot/[L]RewriteRule (.) app/webroot/$1 [L]

在 webroot .htaccess 中<前>重写引擎开启RewriteBase/mycakeappRewriteCond %{REQUEST_FILENAME} !-dRewriteCond %{REQUEST_FILENAME} !-f重写规则 ^(.*)$ index.php [QSA,L]

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

php 是 5.4 版本我该如何解决这个问题?

解决方案

像这样设置你的规则:

.htaccess 在 DOCUMENT_ROOT 中

RewriteEngine on重写基数/RewriteRule (.*) mycakeapp/$1 [L]

.htaccess 在 DOCUMENT_ROOT/mycakeapp 中

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

.htaccess 在 DOCUMENT_ROOT/mycakeapp/app 中

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

.htaccess 在 DOCUMENT_ROOT/mycakeapp/app/webroot 中

RewriteEngine OnRewriteBase/mycakeapp/app/webroot/RewriteCond %{REQUEST_FILENAME} !-dRewriteCond %{REQUEST_FILENAME} !-fRewriteRule ^ index.php [L]

Using the default cakephp htaccess file setup will not work on my domain when I want to install my Cakephp app in a subfolder, while everything works on localhost (xampp)

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

Install needs 3 htaccess files:

root .htaccess

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

in app .htaccess

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

in webroot .htaccess

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

Following cakephp documentation, and Using these htaccess files, I get error500 results. Using RewriteBase / instead of /mycakeapp will throw 404 error page.

php is in 5.4 version How can I solve this?

解决方案

Setup your rules like this:

.htaccess in DOCUMENT_ROOT

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

.htaccess in DOCUMENT_ROOT/mycakeapp

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

.htaccess in DOCUMENT_ROOT/mycakeapp/app

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

.htaccess in DOCUMENT_ROOT/mycakeapp/app/webroot

RewriteEngine On
RewriteBase /mycakeapp/app/webroot/

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

这篇关于如何在 1and1 共​​享主机上为 Cake 2.3.x 配置 htaccess 文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆