Subdirectory shows in the url

I am hosting a website on godaddy, and briefly uploaded the site but the subdirectory shows on the url

E.g, If I click on aboutus, the url that comes up is www.example.com/code/aboutus.html

I will like this to be www.example.com/aboutus when a user clicks on the aboutus link on the page.

More Information

  • I have all my codes in the code folder (subdirectory) and my index code in the main directory.

I tried this
RewriteEngine On
RewriteRule ^aboutus/?$ code/aboutus.html [NC,L]

But it only works when you type www.example.com/aboutus but not when you click on the about link on the site.

Any help will be appreciated

Apache can only take care of the server side of things. I.e., it can internally rewrite /aboutus to /code/aboutus.html.
You still have to update the link in your HTML yourself.
Change
<a href=“/code/aboutus.html”>About us</a> to <a href=“/aboutus”>About us</a>

I would also like to suggest some slight changes to your .htaccess


RewriteEngine On
RewriteRule ^/?aboutus/?$ /code/aboutus.html [L]

  • Remove [NC], not needed (only need when checking information that are case sensitive, folders are not)
  • Add /? at the beginning of the RewriteRule, to make it compatible with Apache 1.x might you ever need it
  • Prepended a / to code/aboutus.html, to make it more clear where it is, and prevent possible problems with this later

ScallioXTX

Thanks alot for the feedback, it works. Have a blessed day