Folder strucure

Problems with the Windows version of XAMPP, questions, comments, and anything related.

Folder strucure

Postby Lykos22 » 19. July 2014 11:27

Hi all, I'd like some info if possible.

I have created a projects folder inside C:\xampp\htdocs where I place all my projects, so in order to access a specific project through the url, I type this:
http://localhost/projects/example

1. Is it possible to set the projects folder as the root folder for all my projects? So basicly when I type localhost on the url, to go by default on C:\xampp\htdocs\projects

2. In every project I try to keep the following folder structure:
Code: Select all
 - projects
 -- example // name of one of my projects
 --- private // contains folders with Core PHP functionality. This will not be accessible through url
 ---- functions, db connection, php scripts here etc etc
 --- public // the public_html directory
 ---- css
 ---- js
 ---- images
 ---- index.php // the index page of my project

If I type http://localhost/projects/example I get the folder structure, instead http://localhost/projects/example/public shows the index.php page.
So basicly what I want to do is when I type http://localhost/projects/example to land me in public/index.php automaticly.

Is it possible to do these 2 things with some .htaccess files??
Lykos22
 
Posts: 11
Joined: 23. September 2011 09:20
Operating System: Windows 7 home edition 64bit

Re: Folder strucure

Postby JJ_Tagy » 19. July 2014 11:38

Yes, all asked is possible. For #1, it sounds like you want to have a .htaccess in htdocs do a temporary redirect to projects folder. #2 would be the same in each base project folder to point to public unless you want to do a URL rewrite to serve the public index while showing projects/example in the address bar.
JJ_Tagy
 
Posts: 678
Joined: 30. January 2012 13:44
Operating System: Windows 10 Pro x64

Re: Folder strucure

Postby Altrea » 19. July 2014 11:50

I would create (sub-)domains for each project and use a folder structure like this (as you see i use the domain name as one foldername):

/projects
  • /example.com
    • /core
    • ...other folder files not accessible by url ...
      • /htdocs <-- DocumentRoot for example.com
        • /css
        • index.php
        • --- other asset files and folders ...
  • /domain.tld
    • /core
    • ...other folder files not accessible by url ...
      • /htdocs <-- DocumentRoot for domain.tld
        • /css
        • index.php
        • --- other asset files and folders ...
We don't provide any support via personal channels like PM, email, Skype, TeamViewer!

It's like porn for programmers 8)
User avatar
Altrea
AF Moderator
 
Posts: 8286
Joined: 17. August 2009 13:05
XAMPP version: several
Operating System: Windows 10 Pro x64

Re: Folder strucure

Postby Lykos22 » 19. July 2014 12:07

Thank you both for your reply, I really appreciate it!

JJ_Tagy wrote:Yes, all asked is possible. For #1, it sounds like you want to have a .htaccess in htdocs do a temporary redirect to projects folder. #2 would be the same in each base project folder to point to public unless you want to do a URL rewrite to serve the public index while showing projects/example in the address bar.


@JJ_Tagy: I'm not very familliar with the commands need to type in both .htaccess files, it sounds like rocket sience to me at the moment :P . Could you please provide me the code I need to type??

@Altrea: not sure whether I understand your example, but this mean that all my projects should be placed outside the htdocs folder?? How would I indentily them through the localhost then?? could you be more thorough?
Lykos22
 
Posts: 11
Joined: 23. September 2011 09:20
Operating System: Windows 7 home edition 64bit

Re: Folder strucure

Postby JJ_Tagy » 19. July 2014 12:49

Altrea's example is a very good suggestion. Especially since you seem to want to organize per project. Subdomains are a good answer. If you want simple redirects, there are many online generators to take care of the code for you such as http://www.ipdistance.com/redirect_generator.php
JJ_Tagy
 
Posts: 678
Joined: 30. January 2012 13:44
Operating System: Windows 10 Pro x64

Re: Folder strucure

Postby Lykos22 » 19. July 2014 13:28

So if I put this .htacces file inside htdocs/projects/example
Code: Select all
RewriteEngine on
Redirect /xampp/htdocs/projects/example/ xampp/htdocs/projects/example/public_html

and type on the url http://localhost/projects/example, will fix the url issue and redirect me to the public_html/index.php page?
Lykos22
 
Posts: 11
Joined: 23. September 2011 09:20
Operating System: Windows 7 home edition 64bit

Re: Folder strucure

Postby Altrea » 19. July 2014 14:25

Lykos22 wrote:this mean that all my projects should be placed outside the htdocs folder??

This structure could also be build inside your existing htdocs folder, but i would not do that because nested virtual hosts are not recommend.

Lykos22 wrote:How would I indentily them through the localhost then??

Localhost is just a simulated domainname for your very own Computer. You can define multiple of such simulated domainnames with the help of your c:\Windows\system32\drivers\etc\hosts file

For each of these simulated domain you can define a VirtualHost in your Apache configuration each listening to their own domain and having their own DocumentRoot
We don't provide any support via personal channels like PM, email, Skype, TeamViewer!

It's like porn for programmers 8)
User avatar
Altrea
AF Moderator
 
Posts: 8286
Joined: 17. August 2009 13:05
XAMPP version: several
Operating System: Windows 10 Pro x64


Return to XAMPP for Windows

Who is online

Users browsing this forum: No registered users and 62 guests