Hardik Deliwala
Hardik Deliwala

Reputation: 1

How can I change my .htaccess file in cakephp

I have URL like :

localhost/admin/app/webroot

For this the css in default.ctp taken /app/webroot/css/style.css path. so my css is not loading.

Should I have to change .htaccess file for this ? There are 3 .htaccess file in project.

1) which is located in admin/.htaccess

RewriteEngine on

RewriteRule ^$ app/webroot/ [L]

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

2) which is located in admin/app/.htaccess

RewriteEngine on

RewriteRule    ^$    webroot/    [L]

RewriteRule    (.*) webroot/$1    [L]

3) which is located in admin/app/webroot/.htaccess

RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-d

RewriteCond %{REQUEST_FILENAME} !-f

RewriteRule ^ index.php [L]

please help to resolve my problem.

Thanks in advance.

Upvotes: 0

Views: 1648

Answers (2)

Hardik Deliwala
Hardik Deliwala

Reputation: 1

I found the answer :

If we can add

Configure::write('App.base', '/admin/');

in bootstrap.php file then it works for me.

Thanks for your help.

Upvotes: 0

the1dv
the1dv

Reputation: 931

The simplest way of dealing with this is to set your application up in "Production Mode" as described here

Essentially it means you point your document root to the /app/webroot directory of your Cake App, this makes everything really simple and means you can use the default .htaccess files to handle the rewriting.

If you are trying to put this into a subdirectory you might need to set the base for Rewrite to work on:

RewriteBase /admin

This also assumes you have mod_rewrite enabled on your server!

Upvotes: 0

Related Questions