mod_rewrite php mysql

前端 未结 4 1781
南旧
南旧 2021-01-16 01:03

I\'m really new at mod_rewrite and i have been trying to figure this out but really stuck. p Here is my issue.

I have a page http://example.com/user/?s=81 ?s=81 is

4条回答
  •  北荒
    北荒 (楼主)
    2021-01-16 01:46

    Here's what I would suggest: if your username is only alphanumeric chars, you could pass the nick to all your Php files, after an internal rewrite, in the GET query.

    Something like:

    RewriteRule /([a-zA-Z0-9]+)$ /user/?s=$1 [QSA,L]
    RewriteRule /([a-zA-Z0-9]+)/(.*)$ /$2?s=$1 [QSA,L]
    

    And then, just have the "mother of mother" classes in Php that check for a value "s" in the query string ($_GET) which checks in the database if the user exists. If the user doesn't exists, make a 404 in Php.

提交回复
热议问题