.htaccess remove question mark from url

后端 未结 2 1186
借酒劲吻你
借酒劲吻你 2021-01-21 21:55

I have a website that has an query string in the url that I want to rewrite. The url is domain.com/profile.php?user=sven and I want it to redirect to domain.c

相关标签:
2条回答
  • 2021-01-21 22:32

    Update your htaccess to following,

    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^/?profile/(.*?)/?$ /profile.php?user=$1 [L]
    RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /profile\.php\?user=([^]+)
    RewriteRule ^/?profile\.php$ /users/%1? [L,R=301]
    </IfModule>
    

    I hope this helps.

    0 讨论(0)
  • 2021-01-21 22:40

    Probaly all the problem here:

    RewriteRule ^profile.php$ domain.com/user/%1?/ [L,R=301]
    

    This may fix your problem.

    0 讨论(0)
提交回复
热议问题