How to use mod rewrite for get variables

I’ve modified my htaccess file to remove .php from the URL:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteCond %{REQUEST_URI} !/$
RewriteRule ^(.*)$ $1\.php

In addition, I have a url that I would like to modify:

http://example.com/record.php?id=1&name=test-record

I would like to rewrite this url to:

http://example.com/records/name where “name” represents the “name” GET variable above. So, the output would be:

http://example.com/records/test-record

How can I do this and is it possible that my code will still read the original GET variables with the new URL?

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s