views:

9

answers:

1

I need help with a rewrite in .htaccess.

I am trying to do the following: When a user types http://www.example.com/csc/alabama/ I need to pull info from http://www.example.com/csc/index.php?state=alabama

I thought it should be this

Options +FollowSymLinks
RewriteEngine On
RewriteRule ^csc/([^/]*)$ /csc/index.php?state=$1 [L]

I keep getting a 404 error.

On a side note, I would like to be able to do this with a generic sub-directory, so that csc could be abc or anything else but this is not the priority.

A: 

You forgot the trailing slash in your pattern. You should also exclude the destination you are redirecting to:

RewriteCond $1 !=index.php
RewriteRule ^csc/([^/]*)/$ /csc/index.php?state=$1 [L]
Gumbo