重定向" mydomain.com/user"到" mydomain.com/name.php~~V ID =用户QUOT?; [英] Redirect "mydomain.com/user" to "mydomain.com/name.php?id=user"

查看:119
本文介绍了重定向" mydomain.com/user"到" mydomain.com/name.php~~V ID =用户QUOT?;的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想我可以使用.htaccess文件对于这一点,但我看着它,并没有发现任何有用的。我想要做的是有我的网站重定向到PHP页面,当用户键入其URL中的用户名,如:

I think I can use the .htaccess file for this, but I've looked it up and not found anything useful. What I want to do is have my site redirect to a php page when a user types their username in the URL like:

example.com/username

和拥有它是一样的PHP页面,如:

And have it be the same as a PHP page like:

example.com/name.php?id=username

我想它显示为 example.com/username 重定向即使经过,但它是没有必要的。任何想法?

I'd like it to display as example.com/username even after it redirects, but it is not necessary. Any ideas?

推荐答案

您可以使用的 的mod_rewrite 透明地改写服务器上的网址。

You can use mod_rewrite to transparently rewrite your URLs on the server.

假设你只拥有用户名以下的领域,这样的事情会做你想要的:

Assuming that you'd only have usernames following your domain, something like this would do what you want:

RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule .+ name.php?id=$0

这篇关于重定向" mydomain.com/user"到" mydomain.com/name.php~~V ID =用户QUOT?;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆