开发者

like twitter url with rewritecond?

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 mak开发者_如何学Pythone /<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.


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
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜