0

I've read a few posts and tutorials on this so far but still not getting the full picture.

I want to shorten my URLs from ?action=viewArticle&articleId=7 to whatever the title is(held in title table on MySQL)

I understand that to do this you replace the messy part with $1, true? and that you also use $ after the character set to signify the start of where you want the server to change.

I just uploaded this code below as .htaccess and then immediately it returned a full page 500 error. I deleted the file. What am I writing wrong?

Options +FollowSymLinks

RewriteEngine On
RewriteRule ^([a-zA-Z0-9]+)/$ ?action=$1&articleId=$2

I put $2 at the end becuase it seemed like the logical progression. I would like to avoid uploading it incorrectly again.

Adam Brown
  • 2,812
  • 4
  • 28
  • 39
  • Please provide a real example of `from url` and desired `to url` so I could help you more accurately – Unamata Sanatarai Mar 22 '13 at 19:39
  • Ok so the real example is like in the post and desired would be the name of the article only. ?action=viewArticle&articleId=7 -> /blog-number – Adam Brown Mar 22 '13 at 21:23
  • possible duplicate of [SEO friendly URL's with .htaccess](http://stackoverflow.com/questions/4547806/seo-friendly-urls-with-htaccess) – JochenJung Apr 08 '14 at 09:48

1 Answers1

1

The $1 $2 represent back references. Those are created by parentheses () Your rule has got only one opening and closing bracket, thus creating only one back reference.

You are getting an error because $2 doesn't exist.

TylerH
  • 20,799
  • 66
  • 75
  • 101
Unamata Sanatarai
  • 6,475
  • 3
  • 29
  • 51