I constantly see website addresses which end without any sort of file extension (so something like "example.com/example/" rather than "example.com/example.html"). So, for a relatively inexperienced web developer, how does one remove the file extension from the end of the URL? Is there just a folder in the address which "/example/" would be referring to (like "example.com would automatically go to example.com/index.html)? Thanks in advance!
In web development, how would one create a URL like example.com/example/ rather than example.com/example.html?
Generally, a web server needs a default extension. HTML, PHP, ASP, etc...they need something. If you have your default page set to index.html, and in that /example/ folder there is an index.html, then the web server will understand the directory contents, as well as /example/index.html
It's sort of understood by the web server..kinda hard to explain. I hope this helps. :)
Reply:If your web server has Apache installed and if you have access to the .htaccess file.
Open up the .htaccess file and add this:
RewriteBase /
RewriteRule ^(.*)/$ $1.html [L]
So in your example if you access: http://www.example.com/example/
(must have trailing slash)
it will really be loading:
http://www.example.com/example.html
on the server(behind the scenes).
Remember that you need to make all of your links and image calls to be absolute. Example: %26lt;img src="http://www.example.com/images/ok.jp...
or they will not load correctly.
The alternative to this, which may be easiest, is to create actual folders.
Reply:The 2nd 'example' in "example.com/example/" actually refers to a subdirectory and not a webpage like "example.html". In the first URL, the page opened is usually index.html or index.htm.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment