个人主页页面的URL,如Facebook个人资料-php [英] profile page url like facebook profile -php

查看:930
本文介绍了个人主页页面的URL,如Facebook个人资料-php的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

任何人都可以请帮我使用.htaccess文件来定制个人资料页面的URL如Facebook个人主页和其他一些社交网站如Twitter。

Could anyone please help me to use .htaccess file to customize the profile page url like facebook profiles and some other social networking sites like twitter .

对于所有谁登录到我的网站的用户的网址是www.mywebsite.com/view/profile。但我想改变这个URL www.mywebsite.com/username~~V。

For all the users who are logged into my website the url is www.mywebsite.com/view/profile. But I want to change that url to www.mywebsite.com/username.

是否有任何其他选项比的.htaccess其他自定义配置文件的链接?

Is there any other option other than .htaccess to customize profile link?

推荐答案

您可以检查了这一点:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*/([a-zA-Z0-9_-]+)|([a-zA-Z0-9_-]+))$ ./profile.php?username=$1 [L]

您可以复制上面的code,然后粘贴到你的.htaccess文件。 该profile.php是你的PHP文件,它会读取用户名。 你可以检查出来通过创建一个profile.php和使用

You can copy the above code and paste it on your .htaccess file. The profile.php is your php file that will read the username. You can check it out by creating a profile.php and use

var_dump($_GET); die();

,你会看到变量$ _GET [用户名] 并从那里你现在就可以查询您的SQL。 *只是要小心的SQL注入和增加一些安全性。

and you will see the variable $_GET['username'] and from there you can now query your sql. * Just be careful for the sql injection and add some security.

这篇关于个人主页页面的URL,如Facebook个人资料-php的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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