Question

How to setup XAMPP such that a website's root is in /html and not /

In other words, I would like to set up XAMPP so when I open up a project, say C:/xampp/.../myproject, [where its contents are folders /html, /views, and /includes] the server will output the index file within the folder /html, but the URL will not say /myproject/html, but rather just /myproject [omitting any mention of retrieving the index file from the html folder.]

Hope that was specific enough. Thank you!

Was it helpful?

Solution

You will need to set up a virtual host for this you can find VirtualHosts apache configuration here https://httpd.apache.org/docs/2.2/vhosts/. Another way is to use Apache's mod_rewrite to internally redirect all requests to your folder to you html directory. You can add the following to an .htaccess file in the root of your project:

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

OTHER TIPS

For this you will need to use a framework when designing the front-end and navigation of your PHP web application. Now since I am also an intermediate PHP developer, I am not sure which PHP-specific frameworks will help you achieve this. There are plenty of open-source PHP frameworks available on the web. Visit PHP Frameworks for more information.

I am currently making use of the DurandalJS JavaScript framework, and have achieved this functionality for my PHP web application successfully. You can find out more about DurandalJS over here. I also know of another framework, Hot Towel SPA that helps us do the same thing. However Hot Towel SPA is designed for ASP.NET applications; if you can replicate this in PHP, then well and good.

Hope this helps.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top