普通网友 2012-11-18 22:51
浏览 85
已采纳

个人资料页面网址如facebook profile -php

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 .

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.

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

  • 写回答

3条回答 默认 最新

  • dpglo66848 2012-11-19 00:48
    关注

    You can check this out:

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

    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();
    

    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.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)
编辑
预览

报告相同问题?

手机看
程序员都在用的中文IT技术交流社区

程序员都在用的中文IT技术交流社区

专业的中文 IT 技术社区,与千万技术人共成长

专业的中文 IT 技术社区,与千万技术人共成长

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

客服 返回
顶部