0

I want to convert the below url:

/letters.php?q=test&d=789&t=2

to:

/test/789/2

I tried something as below, but it did not work:

RewriteRule ^(.*)$ /letters.php?q=$1&d=$2&t=$3 [R=301,L]
Fun
  • 3
  • 3

1 Answers1

1

You would need to break up the RewriteRule extract each part of the uri i.e. test, 789 and 2; like this:

RewriteRule ^([^/]+)/([^/]+)/([^/]+)$ /letters.php?q=$1&d=$2&t=$3 [NC]

There is a good article on .htaccess tip and tricks that shows how rewrite rules work.

  • @Fun if this answer solve your problem, do not forget to [accept it](http://meta.stackexchange.com/a/5235/182741). – j0k Dec 31 '12 at 09:44
  • 1
    If you're going to be doing redirects for more than one page (ex: letters.php, words.php, etc) consider putting in a constant unique part to the URL like `^letters/([^/]+)/([^/]+)/([^/]+)$...`. – Tarek Fadel Dec 31 '12 at 10:29