i would like a simple help…
i have a url like this:
example.com/profile.php?id= & name=
my .htaccess file like this.
RewriteRule ^profile/(.)/(.) profile.php?id=$1&name=$2
so i have a end url like this:
example.com/profile/id/name
i can make
example.com/id
but how can i get a url like this:
example.com/name
??
thax
If what you’re looking for is exactly this:
example.com/name
You will need to change your profile.php to only expect the name variable, and use it to query the database.
I believe previously you had something like:
You will need to change it to be
So you are telling your page to query the user by the name, instead of by the ID.
There’s a few drawbacks related to this, as your query won’t be as fast as it used to be, as I believe your name column is not the primary key, therefore no indexing.
Twitter uses Rails, so they will be calling it in a slightly different way using something like (onMissingMethod):
Which isn’t great either, as it’s still querying the database by a string, but has some performance improvements to enable rails to do that.
Your htaccess will then looki like:
Hope that answers your question