PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Friday, March 18, 2022

[FIXED] How to configure htaccess file for Cake 2.3.x on 1and1 shared hosting

 March 18, 2022     .htaccess, apache, cakephp, mod-rewrite, regex     No comments   

Issue

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?


Solution

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]


Answered By - anubhava
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home
View mobile version

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing