views:

23

answers:

1

I would like a simple help. I have a URL like this: /profile.php?id=<id>&name=<name>.

My .htaccess file like this:

RewriteRule ^profile/(.*)/(.*) profile.php?id=$1&name=$2

So I have a end URL like this: /profile/<id>/<name>.

I can make /<id>. But how can I get a URL like /<name>?

I can use the RewriteCond to make a conditional? I still don't a lot of .htaccess.

A: 

If the names and IDs have a different pattern in their values, you could use these patterns in your rules, for example:

# numerical IDs
RewriteRule ^[1-9]\d*$ profile.php?id=$0

# names
RewriteRule ^[a-z]+$ profile.php?name=$0
Gumbo