Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rewrite GET Query String using .htaccess

I want to Rewrite my GET Query String from this -

http://www.example.com/verify.php?key=547b52f2b5d20d258e62de1e27b55c

to this

http://www.example.com/verify/547b52f2b5d20d258e62de1e27b55c

I am using the following rule but it does not seem to work -

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(([A-Za-z0-9\-]+/)*[A-Za-z0-9\-]+)?$ $1.php

RewriteRule    ^[A-Za-z-]+/([A-Za-z0-9-]+)/?$    verify.php?key=$1    [NC,L]

1 Answers

Use the following:

RewriteEngine On
RewriteCond %{THE_REQUEST} ^GET\ /verify\.php\?key=([^\s&]+) [NC]
RewriteRule ^verify\.php$ /verify/%1? [R=301,L]

RewriteRule ^verify/([^/]+)/?$ /verify.php?key=$1 [NC,L]
like image 194
hjpotter92 Avatar answered Jun 01 '26 22:06

hjpotter92



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!