3

I have downloaded a CakePHP project from an online server and need to make it work locally, to do some changes. I'm facing a problem similar to this one and have tried all possible solutions, with no luck.

Here's the situations:

  • Site home is in localhost/xpto (c:\xampp\htdocs\xpto) -> here, the site appears unformatted (no CSS) and too slow.
  • If I access localhost/xpto/something, I get the site with the CSS, but some links wont work.

I have mod_rewrite loaded (phpinfo()) together with the 3 .htaccess files, but still experience this problem.

Is there any known issue that I can explore to fix my site? Please redirect me to any guides or tutorials that you may feel relevant to my issue

1
  • CakePHP is "just" a a bunch of PHP scripts, it should work out-of-the-box. I'd recommend to give XAMPP a try, it works for me ever since I've installed it the first time. Commented Jun 4, 2012 at 18:16

2 Answers 2

2

Use RewriteBase directive in .htaccess.

e.g my dev space is on my localhost, is located in /home/ati/public_html/cakerbs, under a subdir in my userdir. The rewriteBase looks like as follows in the root of the cake:

<IfModule mod_rewrite.c>
   RewriteEngine on
   RewriteBase /~ati/cakerbs
   RewriteRule    ^$ app/webroot/    [L]
   RewriteRule    (.*) app/webroot/$1 [L]
</IfModule>

in the app directory .htacces:

<IfModule mod_rewrite.c>
    RewriteEngine on
    RewriteBase /~ati/cakerbs
    RewriteRule    ^$    webroot/    [L]
    RewriteRule    (.*) webroot/$1    [L]
</IfModule>

in the webroot directory:

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /~ati/cakerbs
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^(.*)$ index.php?url=$1 [QSA,L]
</IfModule>
Sign up to request clarification or add additional context in comments.

Comments

0

Check your XAMPP apache settings, it's very likely your current config is blocking things like the .htaccess files (I know EasyPHP does this by default with Cake). What I do to get around this error is to add a VirtualHost to my config like such:

<VirtualHost *>
DocumentRoot "C:/xampp/htdocs/xpto/"
ServerName xpto.dev
ServerAlias www.xpto.dev
ErrorLog "logs/xpto-error.log"
CustomLog "logs/xtpo-access.log" common
<Directory />
    Options FollowSymLinks
    AllowOverride All
    Order deny,allow
    Allow from all
</Directory>
</VirtualHost>

It may be better to update your whole config properly, but seeing as it's a dev environment for me, this does just fine. (Don't forget to add any hosts to your windows hosts file)

Then just open your favourite browser and go to http://xpto.dev/ and it should load up.

This may help your more: http://ailoo.net/2008/07/set-up-multiple-virtual-hosts-on-xampp-for-windows/

1 Comment

I did that, but still no luck. If I access http:// project:8081/, where project is a VH in c:\xampp\htdocs\project, I get the problem above. However, if I access http:// project:8081/something, css are loaded but still having problems with some links. Seems like css are not loaded on index (start page). Another thing... this is a project imported from a online server. I've installed a fresh cakephp site locally, and it seems to work properly!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.