Need help to rewrite a dynamic URL (.htaccess)

Any questions involving matching text strings to patterns - the pattern is called a "regular expression."

Moderator: General Moderators

Post Reply
zurih
Forum Newbie
Posts: 8
Joined: Sat Nov 08, 2008 9:20 am

Need help to rewrite a dynamic URL (.htaccess)

Post by zurih »

Hi,

I'm looking for rewrite the following:

From this:

Code: Select all

http://www.test.com/articles.php?article_category=test_category&article_name=test_name
To something like this:

Code: Select all

http://www.test.com/test_category/test_name
How can I do it?
User avatar
GeertDD
Forum Contributor
Posts: 274
Joined: Sun Oct 22, 2006 1:47 am
Location: Belgium

Re: Need help to rewrite a dynamic URL (.htaccess)

Post by GeertDD »

Code: Select all

RewriteEngine On
RewriteCond %{QUERY_STRING} article_category=([a-z_]+)
RewriteCond %{QUERY_STRING} article_name=([a-z_]+)
RewriteRule /%1/%2 [R=301,L]
Not tested.
Also see: http://httpd.apache.org/docs/2.0/mod/mod_rewrite.html
Post Reply