Rewrite mysite.com/app.php?appname=example-name&appid=numeric-id to mysite.com/app/app-name/numeric-id/

后端 未结 2 1157
隐瞒了意图╮
隐瞒了意图╮ 2021-01-26 11:01

I am new to PHP and server-side operations so asking this basic question here. I found a lot of similar questions and answers here but I fail to achieve what I want. How can I w

2条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-01-26 12:02

    Try this in your .htaccess file

    RewriteEngine On
    RewriteRule ^app/(.*)/(.*)/?$ /app.php?appname=$1&appid=$2 [QSA,NC,L]
    

    EDIT :

     RewriteEngine On
     RewriteCond %{THE_REQUEST} app\.php\?appname=(.*?)&appid=([0-9]+) [NC]
    RewriteRule ^ /app/%1/%2? [R=302,L]
    
    RewriteRule ^app/(.*)/([0-9]+)/?$ /app.php?appname=$1&appid=$2 [L,QSA]
    

提交回复
热议问题