mybigadventures.com  home  photos  blog  portfolio  log in

updating the .htaccess file

Wednesday, April 29, 2015

I had looked at a few other blog type sites and decided I wanted to simplify the URLs for the website. After a quick read around on the Internet I came across Apache mod rewrite for the .htaccess file. Now that's more than likely meaningless to anyone that might look at the site and up until very recently didn't mean a lot to me either. After having a looking on a couple of different websites, it seemed to achieve what I was looking for with very little effort.

To begin with I had to create a .htaccess file in notepad as there wasn't one in the root directory of my hosting account.

I started by adding:

Options +FollowSymLinks -Multiviews

This enabled mod rewrite on my hosting account with godaddy

I then started by removing the requirement for .php at the end of my php pages. I copied and pasted the code for this from a site I came across:

RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^ %{REQUEST_URI}.php [L]
 

I then added a few custom rewrites to simplify access of the blog and album elements of the website. Having very little experience of mod rewrite I was really pleased to find an automated tool in the shape of www.generateit.net/mod-rewrite/index.php.

That's pretty much it, now I have super simple URLs instead of those long php parameterised ones that I had before!

See More: #programming #website 
profile imagePosted by Ben Taylor
at 20:30
comments 0