I would like to link to pages inside my website, e.g: Not: mywebsite.com/about.html But: mywebsite.com/about/
I've seen various websites doing this but it looks like they also react differently to things:
Apple.com: apple.com/iphone/ works, apple.com/iphone/index.html works, apple.com/iphone redirects.
Opera.com: opera.com/mobile/ redirects, opera.com/mobile works, opera.com/mobile.html does not work.
Mozilla.com: mozilla.org/en-US/ works, mozilla.org/en-US redirects, mozilla.org/en-US/index.html does not work.
Which leads to another question: Are there different methods for this?
Edit: It seems that Apple uses a folder for every page, e.g. a folder called 'iphone' with an index.html file inside it? But Opera and Mozilla use something in the .htaccess file?
The . html extension can be easily removed by editing the . htaccess file. .
There's no difference between them, and you can use either on most web servers. As the original extension for HTML pages on Unix web hosting machines, . html indicates a file that uses HTML (HyperText Markup Language) or XHTML (EXtensible HyperText Markup Language).
The only way to see a different URL is to proxy the response, or putting it in a frame. The only way to "hide" your URL would be to use frames.
Removing Extensions
To remove the .php extension from a PHP file for example yoursite.com/wallpaper.php to yoursite.com/wallpaper you have to add the following code inside the .htaccess file:
RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^([^\.]+)$ $1.php [NC,L]
If you want to remove the .html extension from a html file for example yoursite.com/wallpaper.html to yoursite.com/wallpaper you simply have to alter the last line from the code above to match the filename:
RewriteRule ^([^\.]+)$ $1.html [NC,L]
That’s it! You can now link pages inside the HTML document without needing to add the extension of the page. For example:
<a href="http://whatever.com/wallpaper" title="wallpaper">wallpaper</a>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With