Search code examples
phpapachelocalhost

XAMP / Apache - Folders in htdocs as root?


i'm trying to set up a local development environment using XAMP as my localhost.

My issue is, that i place my projects in sub-folders in the htdocs folder.

This means my directory structure is:

localhost/myProject/index.php

However, that also means the "root" of my project is "localhost" and not "localhost/myProject" as i want it to be.

Any advice on how i fix this?

For total clarity, the reason why i wanna fix it is that i use CakePHP, and it has a structure like: "root/controller/action", but since it is placed in a folder in htdocs, i access it like: "localhost/myProject/controller/action" - the issue is, that it thinks "myProject" is the controller to look for. This is what i am trying to fix. If you have any ideas, please, for the love of god help me

HTACCESS UPDATE

Root .htaccess:

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

RewriteBase /bakesystem

#Rewrite everything to https
RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

webroot .htaccess

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]

#Rewrite everything to https - disabled on test

#RewriteEngine On
#RewriteCond %{HTTPS} !=on
#RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

Solution

  • You have got rewrite engine twice in the root .htaccess. Go back to your default htaccess (If you don't have a backup copy, get it from a fresh cakephp project).

    And then try to set project root at your config file (/app/Config/core.php)

    Configure::write('App.fullBaseUrl', 'http://example.com');

    Change this to your base url and update me..