I am running into an infinite redirection loop when setting up CakePHP on a bluehost server.
I have set my .htaccess as follows,
Under /home/mysite/public_html/site2 (I have configured an add-on domain with site2 as its serving directory on BlueHost)
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^$ app/webroot/ [L]
RewriteRule (.*) app/webroot/$1 [L]
</IfModule>
Under /home/mysite/public_html/site2/app as,
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^$ webroot/ [L]
RewriteRule (.*) webroot/$1 [L]
</IfModule>
And finally under /home/mysite/public_html/site2/app/webroot as,
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>
If I remove the two RewriteCond from the .htaccess under webroot the Cake controllers start working but I don't see any images or CSS. I am not sure where am I going wrong.
creat a htaccess in root same as
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{HTTP_HOST} ^site2\.tld[NC]
RewriteRule ^$ site2/app/webroot/ [L]
RewriteCond %{HTTP_HOST} ^site2\.tld[NC]
RewriteRule (.*) site2/app/webroot/$1 [L]
</IfModule>`
and htacess in site2 folder must be
RewriteEngine on
RewriteRule ^$ app/webroot/ [L]
RewriteRule (.*) app/webroot/$1 [L]
Related
Here are the htaccess codes that CakePHP uses:-
I want to rewrite them/ convert them so that they run on my openlitespeed server. They work perfectly fine on a standard apache server.
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^$ app/webroot/ [L]
RewriteRule (.*) app/webroot/$1 [L]
</IfModule>
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^$ webroot/ [L]
RewriteRule (.*) webroot/$1 [L]
</IfModule>
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php [QSA,L]
</IfModule>
Simply add rewrite rules in Context of the virtual host you want.
Add static context of the virtual host
Parameters of context:
- URl = /
- Location = default path e.g. /usr/local/lsws/Example/html/
- Accessible =Yes
- Enable Rewrite = Yes
- Rewrite Rules=
RewriteRule ^(.*)$ app/webroot/ [L]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php [QSA,L]
You can still put all your original rules to rewrite.
I just put one rule RewriteRule ^(.*)$ app/webroot/ [L] because I don't understand why need other rules. webroot/ and webroot/$1 seem never be matched.
RewriteRule ^$ app/webroot/ [L]
RewriteRule (.*) app/webroot/$1 [L]
RewriteRule ^$ webroot/ [L]
RewriteRule (.*) webroot/$1 [L]
I am getting the error(mysite.com/cake-284/users/login):
404 - File or directory not found.
-after uploading the Cakephp 2.8.4 sub-directory to my PHP website in the live host.
But the subdirectory root(mysite.com/cake-284) shows:
500 - Internal server error.
The site is running fine in the localhost by the wamp server (PHP Version 5.5.12).
I believe this is the problem of my .htaccess file(s). After searching for a solution, I found Set up CakePHP in a subdirectory; Wordpress is installed in the root, and cakephp inside a subdirectory. But these didn't help.
There is no .htaccess file in the root.
mysite.com/cake-284/app/webroot/.htaccess :
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php?url=$1 [QSA,L]
</IfModule>
mysite.com/cake-284/app/.htaccess :
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^$ webroot/ [L]
RewriteRule (.*) webroot/$1 [L]
</IfModule>
mysite.com/cake-284/.htaccess :
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^$ app/webroot/ [L]
RewriteRule (.*) app/webroot/$1 [L]
</IfModule>
Cakephp 2.8.6, PHP Version: 5.5.35
I don't know if there is anything else to do with the rewrite.
Edit .htaccess with you sub directory
mysite.com/cake-284/app/webroot/.htaccess :
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /cake-284
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php?url=$1 [QSA,L]
</IfModule>
mysite.com/cake-284/app/.htaccess :
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /cake-284
RewriteRule ^$ webroot/ [L]
RewriteRule (.*) webroot/$1 [L]
</IfModule>
mysite.com/cake-284/.htaccess :
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /cake-284
RewriteRule ^$ app/webroot/ [L]
RewriteRule (.*) app/webroot/$1 [L]
</IfModule>
I am having an issue with the .htaccess file i think. I recieve constant internal 500 errors. I have tried many different solutions around the web. Here is what my .htaccess files look like:
ROOT ACCESS
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^$ app/webroot/ [L]
RewriteRule (.*) app/webroot/$1 [L]
</IfModule>
app/ HTACCESS
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^$ webroot/ [L]
RewriteRule (.*) webroot/$1 [L]
</IfModule>
app/webroot/ HTACCESS
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php [QSA,L]
</IfModule>
Notice: my project is in root directory - public_html/
askpapa.in/askpapaFinal is opening fine.
See the problem here
root htaccess file
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /askpapaFinal/
RewriteRule ^$ app/webroot/ [L]
RewriteRule (.*) app/webroot/$1 [L]
</IfModule>
App Folder Htaccess file
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /askpapaFinal/
RewriteRule ^$ webroot/ [L]
RewriteRule (.*) webroot/$1 [L]
</IfModule>
webroot htaccess
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /askpapaFinal/
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>
I have installed my cakephp on a shared host server.
I always get a 404 error
The mod_rewrite looks like this
/home/user/public_html/cms/.htaccess
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^$ app/webroot/ [L]
RewriteRule (.*) app/webroot/$1 [L]
</IfModule>
/home/user/public_html/cms/app/.htaccess
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^$ webroot/ [L]
RewriteRule (.*) webroot/$1 [L]
</IfModule>
/home/user/public_html/cms/app/webroot/.htaccess
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php?url=$1 [QSA,L]
</IfModule>
The url is http://server/~user/cms and the server path is /home/user/public_html/cms
you have to add the RewriteBase to remove http://server/~user/ from the url. cake does not work with ~ in the url