I usually do not want to put my webprojects inside the htdocs directory in the default Xampp setup. Depending on the type of project I want them in different places. One simple way to run them from htdocs (localhost/projectname) is to make symbolic links to the projects in the htdocs folder. Here is how I did it:

1. Navigate to the htdocs folder in the Xampp package, normaly ‘/Applications/XAMPP/htdocs/
2. Run the command ‘ln -s <path to project>‘. Eg ‘ln -s /Users/niklas/NetBeansProjects/project1

This will create a symbolic link called ‘project1‘ in you htdocs directory pointing to the ‘/Users/niklas/NetBeansProjects/project1‘ directory. 

Apache will, with the default settings, run the project as if it really was inside the htdocs directory. Just navigate to ‘http://localhost/project1‘ and enjoy the result

There are other ways to accomplish the same result but this it the solution I like the best