douyun1852 2014-11-11 08:30
浏览 16
已采纳

重写配置文件页面的URL

How do I use .htaccess to rewrite:

mysite.com/profile/[username]

go to:

mysite.com/profile.php?id=[username]

I don't want to have to reload the page just change the URL to make it look good.

Any help is appreciated.

  • 写回答

1条回答 默认 最新

  • doudu8291 2014-11-11 08:32
    关注

    This is the htaccess rule that should get you started:

    RewriteEngine On
    
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule profile/(.+) profile.php?id=$1
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?