Htaccess Clean URL's

By gilbitron in Other on 23/02/2009 at 02:56

Views: 1586
Tagged: php, htaccess

Starter:

A basic example of how to use .htaccess to create clean urls on your website.

Main Course:

#.htaccess
 
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^(.*)$ index.php?page=$1 [L]
</IfModule>
 
# http://www.example.com/contact -> 
# http://www.example.com/index.php?page=contact
#
# <?php
# // Get the data from the url
# $url_segments = explode("/", $HTTP_SERVER_VARS['PATH_INFO']);
# ?>

Expand Report Code | Install Coda Clip

Please log in to vote.

Compliments to the Chef

  1. Comment by Darren on 25/04/2010 at 14:19

    I think the author could have spent 5 more minutes and elaborated on how this is supposed to work. Tried to get it working, just couldn't.

    Some basic questions include:
    1. This is meant to go into the .htaccess right?
    2. Why is there commented code here? Why?
    3. Isn't that PHP code? Why is there PHP code in a .htaccess file?

    I'm sending the dish back to the kitchen. It's cold.

How was your Meal?


  • Allowed HTML: <b><strong><u><i><em><a>

  • Why ask? It helps us stop spam comments.