-1

I have created a rule for the .htaccess in order to show static urls instead of dynamic ones.

This is the dynamic url:

www.example.com/user.php?id=410&Name=Dave&Surname=Watson

converted into static:

www.example.com/registered-user-410-Dave-Watson.html

The rule I am using is:

Options +FollowSymLinks
RewriteEngine On
RewriteRule ^example-([^-]*)-([^-]*)-([^-]*)\.html$ /user.php?id=$1&Name=$2&Surname=$3 [L]

The static URL I would like to have is following:

www.example.com/registered-user-Dave-Watson.html

If I use this rule:

RewriteEngine On
RewriteRule ^example-([^-]*)-([^-]*)\.html$ /user.php?id=410&Name=$1&Surname=$2 [L]

I obtain the desired result but all users show the information of the user with the id 410.

Could you please help me to find a solution?

sodskat
  • 125
  • 1
  • 9
  • 1
    Can you explain, when you think logically for one minute, how can a computer know that you want to load information about user 410 if you **never give it that information whatsoever**? Also, the examples you posted - dynamic URL contains 410, static one contains 222. Then you remove the number completely from the URI, replace it with a static number and wonder how all users show user 410. I mean really.. you don't have to know programming at all to see the glaring dumb problem in question. Simply put - you can't "hide" that number if you need it. – N.B. Aug 04 '14 at 13:20
  • @N.B. I expect the OP is expecting that some magic is happening here behind the scenes when in fact URLs are just plain exactly what you see and nothing more. Common misconception IMO. Closed as duplicate of basic explanation what exactly is going on here. – deceze Aug 04 '14 at 13:45

1 Answers1

3

If your URL is www.example.com/registered-user-Dave-Watson.html, then that's all the information that's available. You cannot magically conjure some matching number up out of nothing. If you want this kind of URL, you need to make sure your content is addressable using only this URL. E.g., you make sure that you can locate the right user in your database using only the string "Dave-Watson".

deceze
  • 471,072
  • 76
  • 664
  • 811