Forwarding Users from /FinalProject
Once you start your server in the root of your project, you can click the /finalProject link in the left-hand sidebar. At this point, though, there is no file there to display, so your customers may instead see a directory listing of your folder. This is usually a bad outcome for several reasons:
- It does not look professional.
- It does not have very good aesthetics.
- Showing your folder structure and code is poor practice, because bad actors may be able to find vulnerabilities and compromise your site.
Ultimately, we want users to be sent to finalProject/public. To make that happen, and to add a little more privacy and security, we will force anyone who lands on /finalProject to be redirected automatically to the finalProject/public folder, where the index.bxm file will be served by default. We’ll use a <meta> tag to do this.
Copy the code below and paste it into the file finalProject/index.bxm.
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="refresh" content="0; url=/finalProject/public/">
<title>Redirecting...</title>
</head>
<body>
<p>If you are not forwarded automatically, <a href="/finalProject/public/">follow this link</a>.</p>
</body>
</html>
Save the file and navigate to the /finalProject page in your browser. You should no longer see the directory listing. Instead, you will be taken to the /finalProject/public/index.bxm page, where you can see our rotating carousel.
This happens because the browser sees <meta http-equiv="refresh" content="0; url=/finalProject/public/">, which tells it to refresh the page immediately (after 0 seconds) and load the content from /finalProject/public/. In case their browser does not automatically forward them, we also have the link to the desired location and clear directions as to what to do next.