how to connect my css files in a cakephp website? - cakephp-2.0

I want to use my css file.
I used
$this->Html->css(array('style'), array('charset'=>'utf-8', 'inline' => false));
But this code keeps pointing 'myPageFolder/css/style.css'.
Not 'myPageFolder/app/webroot/css/style.css'
How can I make that code point /app/webroot/css/style.css

Try below code
<?php
echo $this->fetch('css');
echo $this->Html->css('style');
?>
root htaccess yourapp/.htaccess
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^$ webroot/ [L]
RewriteRule (.*) webroot/$1 [L]
</IfModule>
htaccess found in yourapp/app/.htaccess
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^$ webroot/ [L]
RewriteRule (.*) webroot/$1 [L]
</IfModule>
htaccess inside webroot /app/webroot/.htaccess
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>
please check also index.php found in the root directory yourapp/index.php
<?php
define('APP_DIR', 'app');
define('DS', DIRECTORY_SEPARATOR);
define('ROOT', dirname(__FILE__));
define('WEBROOT_DIR', 'webroot');
define('WWW_ROOT', ROOT . DS . APP_DIR . DS . WEBROOT_DIR . DS);
if (!defined('CAKE_CORE_INCLUDE_PATH')) {
define('CAKE_CORE_INCLUDE_PATH', ROOT . DS . 'lib');
}
require APP_DIR . DS . WEBROOT_DIR . DS . 'index.php';
?>

Related

How to remove index.php from url in cakephp 2

I have tried commenting this line present in congif/core.php,
// Configure::write('App.baseUrl', env('SCRIPT_NAME'));
But when I hit my url it gives me 404 error.
Make sure you are loading mod_rewrite correctly. You should see something like
#uncomment it by removing leading #
LoadModule rewrite_module libexec/apache2/mod_rewrite.so
Verify that your .htaccess files are actually in the right directories. Some operating systems treat files that start with ‘.’ as hidden and therefore won’t copy them.
#CAKEPHP root .htaccess
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^$ app/webroot/ [L]
RewriteRule (.*) app/webroot/$1 [L]
</IfModule>
#Cakephp App directory .htacess
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^$ webroot/ [L]
RewriteRule (.*) webroot/$1 [L]
</IfModule>
#Cakephp webroot directory .htaccess
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php [QSA,L]
</IfModule>
URL_REWRITING
You may fix it with your web-sersver (.htaccess rules for apache, rules in configuration file for nginx).

Rewrite rule (if index.html do nothing) for .htaccess

Im trying the find a rule that says: "if index.html part of url then do nothing"
Routes
localhost/rest/token <== Symfony REST backend
localhost/index.html/dashboard <== AngularjS frontend
.htaccess
DirectoryIndex app.php
<IfModule mod_php5.c>
php_value memory_limit 1024M
php_value max_execution_time 600
</IfModule>
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_URI} !^admin
RewriteCond %{HTTP:Authorization} ^(.*)
RewriteRule .* - [e=HTTP_AUTHORIZATION:%1]
RewriteCond %{REQUEST_URI}::$1 ^(/.+)/(.*)::\2$
RewriteRule ^(.*) - [E=BASE:%1]
RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteRule ^app\.php(/(.*)|$) %{ENV:BASE}/$2 [R=301,L]
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule .? - [L]
RewriteRule .? %{ENV:BASE}/app.php [L]
</IfModule>
<IfModule !mod_rewrite.c>
<IfModule mod_alias.c>
RedirectMatch 302 ^/$ /app.php/
</IfModule>
</IfModule>
At the top of your htaccess, put the following
RewriteEngine on
RewriteRule index\.html - [L]
This will exclude the index.html from your all rewriteRules.

OVH deployment - cakephp 2.x

It's my first deployment on a server, and I have a white page. I tried several .htaccess, several dispositions, but it never worked.
Here is the /.htaccess file :
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^$ /app/webroot/ [L]
RewriteRule (.*) /app/webroot/$1 [L]
</IfModule>
Here is /www/.htaccess :
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php?url=$1 [QSA,L]
</IfModule>
My arborescence looks like that :
.bash_logout
.bash_profile
.bashrc
.htaccess
.ovhconfig
Config/
Console/
Controller/
Lib/
Locale/
Model/
Plugin/
Test/
Vendor/
View/
app/
cakephp/
index.html
tmp/
www/
And in www, the content of app/webroot. I changed debug to 0, I tried several things, but I don't understand much of that. Does anyone know what's wrong or missing?
I finally found out : my index.php files weren't correct. I used the real root of the server, homz.800/, instead of just /, and it worked. To have css working properly, I've put the content of webroot, in the app folder, in www.
Here is a good practice to keep your app/ & lib/ folders outside the public box.
Main directory structure (/ is your root directory) :
/
.bash_history
.bash_logout
.bash_profile
.bashrc
.forward
.htaccess
cake_2.x.x/
app/
Config/
Console/
[...]
lib/
Cake/
[lib_subfolders]
[...]
www/
.htaccess
index.php
[js]
[css]
[images]
[...]
Here is the first .htaccess in root path /
SetEnv PHP_VER 5_3
SetEnv REGISTER_GLOBALS 0
The .htaccess in www/
SetEnv PHP_VER 5_3
SetEnv REGISTER_GLOBALS 0
Options -Indexes
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php [QSA,L]
RewriteCond %{HTTP_HOST} ^your_domain.com$
RewriteRule ^(.*) http://www.your_domain.com/$1 [QSA,L,R=301]
</IfModule>
Here is the index.php file inside www/ (important)
[...]
if (!defined('ROOT')) {
define('ROOT', DS . 'homez.800' . DS . 'your_domain');
}
[...]
if (!defined('APP_DIR')) {
define('APP_DIR', 'cake_2.x.x' . DS . 'app');
}
[...]
define('CAKE_CORE_INCLUDE_PATH', ROOT . DS . 'cake_2.x.x' . DS . 'lib');
Take care that your debug mode was set to 0 in app/Config/core.php
Configure::write('debug', 0);
No need of .htaccess and index.php inside app/ you can remove them.
Hope it will help!

My cakephp 2.2 site not working on subdomain

My cakephp 2x site working fine on my local machine.
But i have upload on sub domain server it is not working.
I want my cakephp site working on sub domain with admin Prefix
http://vertaxtechnology.com/ => is my domain
http://dev.vertaxtechnology.com/ = is my sub domain
http://dev.vertaxtechnology.com/eventapp = is my cake directory
This is my Root htaccess
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /eventapp/
RewriteRule ^$ app/webroot/ [L]
RewriteRule (.*) app/webroot/$1 [L]
</IfModule>
This is my app htaccess
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /eventapp/
RewriteRule ^$ app/webroot/ [L]
RewriteRule (.*) app/webroot/$1 [L]
</IfModule>
This is my webroot htaccess
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php [QSA,L]
</IfModule>
Please help thanks

Installing/Setting cakePHP on Server

I'm trying to setup my cakephp work on server
Purchased godaddy shared server
when i go to my site http://xyz.com/cake/
I'm getting 404 error
The requested URL /xyz/cake/app/webroot/ was not found on this server.
anyhelp plz ??
Thanks,
Satish
You need to set the correct RewriteBase in your .htaccess if you're going to run Cake inside a subdirectory.
Both /xyz/cake/.htaccess and /xyz/cake/webroot/.htaccess (assuming /xyz/cake is the path to Cake and your app dir) need to be updated.
/xyz/cake/.htaccess:
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /xyz/cake/
RewriteRule ^$ webroot/ [L]
RewriteRule (.*) webroot/$1 [L]
</IfModule>
/xyz/cake/webroot/.htaccess:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /xyz/cake/
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php?url=$1 [QSA,L]
</IfModule>

Resources