Lego2012
9/26/2016 - 8:58 PM

htaccess Clean URLs

htaccess Clean URLs

# http://socreativedigital.com/7-htaccess-file-examples-that-work-for-seo-2013-05-04
# The next thing the htaccess file helped me with were clean URL’s. I was
# informed by non other then Nibbler, that my URL’s had extensions (how awful)
# and that I must rewrite them in order to make them easier for my visitors to
# remember, to make them more search engine friendly and for better security.
# A clean URL looks like this:
#
# http://www.lakanephotography.co.uk/blog/lee-allan-kane-blog
#
# as apposed to an ugly URL which looks like this:
#
# http://www.lakanephotography.co.uk/blog/lee-allan-kane-blog.html
#
# A clean URL means to serve a webpage without its extension which in my case was the .html
#
# A Google search eventually came up with this code which removes the webpage extension for HTML:
#
RewriteBase /
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.html -f
RewriteRule ^(.*)$ $1.html
#
# This code also works for PHP all you do is replace the [html] with [php] and to Nibblers
# delight, it works!
#
# IMPORTANT! To enable this code to work, you have to remove the .html extension from the
# links within your webpage HTML like this:
#
# <a href=”lee_allan_kane_photography.html”>……</a>
# <a href=”wedding-photography.html”>……</a>
#
# should look like
#
# <a href=”lee_allan_kane_photography”>……</a>
# <a href=”wedding-photography”>……</a>
#
# Which can means if you build your website offline in a folder as i do, then the links
# will stop working! This is the case for HTML but i think the PHP guys build them on a
# live server so it wouldn’t make any difference.