tags:

views:

76

answers:

1

I'm new to PHP and i was trying to learn mod rewrite to rewrite my URLs i use godaddy as my hosting company and they say to add the desired code to the body of your .htaccess file how do I mod rewrite my URLs and add it to my .htaccess file?

Can some one give me an example of how to do this as well as point me to a good tutorial and or book on how to mod rewrite my URLs?

A: 

http://articles.sitepoint.com/article/guide-url-rewriting

A note, though, goDaddy normally requires RewriteBase /

Quick 'n dirty

RewriteEngine On
RewriteBase /
RewriteRule ^/?about/?$ about.php [L,NC,QSA] # domain.com/about is sent to the server as domain.com/about.php
RewriteRule ^/products/([0-9]+)$ /products.php?id=$1 [L,NC,QSA]  # domain.com/products/23 is sent to the server as domain.com/products.php?id=23 
Dan Heberden
would I have to do this for every folder and subfolder?
max
only if you want rules specific to them.. e.g. folder /secretArea might have it's own htaccess file for who knows what. Typically, you'll find them in the root of the site.
Dan Heberden