CakePHP installation on Production with subdomains - cakephp

I have installled my Cakephp based website on my production site like following way
var/html/
app/
cake/
.htaccess etc
Its working perfectly untill I installed Blog. To make it work, I moved my content of blog folder to webroot, now my structure is
var/html/
app/
webroot/
blog/
cake/
.htaccess etc
This works thanks to those .htacess files
Now I am making a subdomain "m
"
ie http://www.m.example.com
My questions are...
Am I doing it right way?
Should I just move every subdomain etc to webroot?
Should I modify htaccess to acheive followwing structure
var/html/
app/
webroot/
cake/
.htaccess
blog/
m/
subdomain/

I would recommend separating them like this. The cake1.3 could be any name you want but the idea is that each framework should have its own descriptive folder.
This makes it much cleaner and is definitely necessary when you get into adding your projects to repositories like git. Each folder can then have its own .htaccess files and being separately configured in your apache config.
var/html/
cake1.3/
app/
webroot/
cake/
blog/

Related

CakePHP 2 path to webroot dir

How to create $this->Html->link(); to download file from Plugin webroot directory?
It's possible?
Why do you have to put the file in Plugin folder to be downloaded. This is not a good practice. Keep the file in webroot/file/name_of_folder
to get the path to webroot/ simply:
debug(WEBROOT);
Prefix with the plugin name
As mentioned in the docs, you can download plugin assets if the request url is prefixed with the plugin name (lower cased and underscored):
Simply prepend /plugin_name/ to the beginning of a request for an asset within that plugin, and it will work as if the asset were in your application’s webroot.
Note however that if the file is intended to be public it's a better idea for the asset to actually be in the webroot:
But keep in mind that handling static assets, such as images, Javascript and CSS files of plugins, through the Dispatcher is incredibly inefficient. It is strongly recommended to symlink them for production. For example like this:
ln -s app/Plugin/YourPlugin/webroot app/webroot/your_plugin
This would make it possible to access all files in a plugin's webroot directly without any rewrite or php logic being involved.

Cakephp subdomain in subdirectory not loading static files

I have CakePHP in a subfolder public_html/cakedir, the folder being accessed from http://cakedir.mydomain.com. Everything seems to be working so far except that the static files are not being found, giving me 404 on the css files.
I'm unable to find anything useful on this issue, though it seems like something straightforward, so perhaps I'm just searching the wrong terms.
Thanks
This was a problem with the .htaccess file in webroot. Add RewriteBase /cakedir/app/webroot/ after RewriteEngine On and it'll work!

CodeIgniter - Project is main website

This may be a potentially really, really dumb question.
So my CI project is going to be our main company website. I have created it here:
www.example.com/CodeIgniter_2.1.3
How do I get my users redirected to that when they just visit www.example.com/ and have it stay www.example.com in the URL?
Is this a .htaccess file thing? Or do I need to move my folders up a level?
CodeIgniter's default behavior is to hide it's actual path. You should only need to copy the .htaccess to the document root, and modify the path to include CodeIgniter_2.1.3
i.e:
RewriteRule ^(.*)$ /CodeIgniter_2.1.3/index.php?/$1 [L,QSA]
So you have put the CI files in a directory called Codeigniter?

CakePHP Subcake Redirect

I have a problem with CakePHP (1.3) project, i need to create projects inside the same domain/hosting of other project, like this:
app
cake
plugins
templates
vendors
ADMINONE (Cake project files here)
ADMINTWO (another Cake project files here)
.htaccess
index.php
README
The problem is, when I put the CakePHP code inside ADMINONE or ADMINTWO to create the other cake projects, if I put the url http://domain.com/ADMINONE/, the URL redirects to http://domain.com or the cake read the /ADMINONE as a controller name.
How can I redirect this URL to the directory ignoring the primary directory cake's redirect?
Dont forget to change your index.php inside the webroot folder. In there you can set up the
APP_DIR and the ROOT if need be.

Setting up Smarty directories and paths

Just a general question for those of you working with the Smarty templating engine.
How are you setting up your file structure? I'd like to follow an MVC format, but I'm not sure how to include all the CSS, Javascript, etc. with the Smarty controller and templates without including these ridiculous paths.
Has anyone worked with this? Anyone have any insight?
Thanks!
Matt
mmmmmm
I would recommend another structure.
suppouse this:
document root: my_app/public_html/
my_app/
- lib
- app
- public_html/
- css/
- js/
- images/
- cache/
- compiled_templates/
- templates/
- mails/
- html/
- text/
- frontend/
- backend/
- xml/
in this was your templates are outside the document root, so.. are protected. In the other way.. anyway can go to my/site/templates/somefile.tpl
your _public_html_ folder should contain all files that users can access.
the lib folder contains the all utility classes you may use: smarty, database, etc..
the app folder contains all the bussines files, etc..etc.
anyway I think the most important point is to have the frontend and the backend in different levels.
saludos
/
/includes/smarty
/includes/class.foobar.php
/includes/class.foobar2.php
/templates/myTemplate.tpl
/templates_c/
/js/
/js/jquery/jquery.js
/css/
/css/style.css
...
works nicely
including a file, which loads all stuff:
require_once 'includes/class.foobar.php';
require_once 'smarty/Smarty.class.php';

Resources