Aliaspooryorik
ColdFusion ORM Book

Enabling Url Rewriting on Apache

Just a quick note to myself (not that I've just wasted half an hour setting up a collegues machine), that if you want to rewrite urls using an .htaccess file then you need to add it to your VirtualHost config and enable the rewrite module in the http.conf file.

To get Apache to load the rewrite module, find the http.conf file, if you are using XAMPP the file path is C:\xampp\apache\conf\http.conf.

Open it up in a text editor and search for the line:


#LoadModule rewrite_module modules/mod_rewrite.so

Remove the comment so that you have:


LoadModule rewrite_module modules/mod_rewrite.so

Save the file.

Now you need to update your VirtualHost configuration to use the .htaccess file. Open the http-vhosts.conf file (if you are using XAMPP the file path is C:\xampp\apache\conf\extra\http-vhosts.conf) and add:


AccessFileName .htaccess

So you will now have something like this:


<VirtualHost *:80>
ServerName localhost.aliaspooryorik.com
DocumentRoot "C:\xampp\htdocs\aliaspooryorik"
DirectoryIndex index.cfm
AccessFileName .htaccess
ErrorLog logs/localhost.aliaspooryorik.com-error_log
CustomLog logs/localhost.aliaspooryorik.com-access_log common
</VirtualHost>

Restart Apache and everything should work just fine :)

 

 


2 comments

  1. Thanks - clearest instructions yet.

    Now to work out what to put into .htaccess :|


    Cheers,
    crispin

    Comment by Crispin – January 19, 2011
  2. Thanks..it's awesome..really helped me..thanks a lot..

    Comment by Ruchi – February 24, 2012

Leave a comment

If you found this post useful, interesting or just plain wrong, let me know - I like feedback :)

Please note: If you haven't commented before, then your comments will be moderated before they are displayed.

Please subscribe me to any further comments
 

Search

Wish List

Found something helpful & want to say ’thanks‘? Then visit my Amazon Wish List :)

Categories

Recent Posts