Jump to content

How to hide web address file extension


lewerjason

Recommended Posts

You need to add a .htaccess file to your server or add the code to a .htaccess file that is there already. You need an Apache server to use .htaccess

http://www.blogstorm.co.uk/htaccess-mod_rewrite-ultimate-guide/

 

The above tutorial is to delete index.html from the url (as well as doing other things as shown to make www the same as no www) but you can edit and repeat for any filename and you can leave it like www.mydomain.com/about instead of www.mydomain.com/about.html

 

You may need to google a general .htaccess tutorial as it can be quite tricky.

 

I have heard that it can be difficult to upload .htaccess as it starts with a . period, so in that case save and upload as temp.htaccess and edit on the server to just .htaccess

Edited by Wickham
Link to comment
Share on other sites

One other thing you can do, if you are working on a small site... You can have a separate folder for each page, each folder containing an "index.html" file, and then link to the folder itself, rather than the file name. For example, here's a sample file structure:

 

-- index.html (your home page)

-- about folder

------ index.html (your about page)

-- contact folder

------ index.html (your contact page)

 

If you were linking to these files, you'd want to link to "/" (home page), "/about" (about page) or "/contact" (contact page). The server is smart enough to look for the default file within each folder, and the "index.html" part will never show in the browser unless you specifically link to the file name.

Link to comment
Share on other sites

I agree with Ben, that is perhaps the best solution. Like you, I was pulling my hair out trying to hide extensions for a small site using .htaccess several years ago and was not successful. Your files most like have to be dynamic in the sense that it has to be interpreted by a server.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...