How to remove empty URL value parameter with HTACCESS

Viewed 24

Hi i want to remove the empty URL value parameter with HTACCESS. Right now i've managed to get http://localhost/TEST/formpage?model=tshirt&color=&size= to just http://localhost/TEST/formpage?model=tshirt. But when i add the third value of size and emptied the second value of color, it won't work. So when i input model=tshirt color='empty' and size=S, it just shows http://localhost/TEST/formpage?model=tshirt. How can i get it worked ? in the future there will be another value not just 3. Here is my current code

<form method="get" id="form">
    <input type="text" name="model" id="model" /> 
    <input type="text" name="color" id="color" /> 
    <input type="text" name="size" id="size" /> 
    <input type="submit" value="sumbit" />
</form>

And the Htaccess code :

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.*)$ $1.php [NC,L]

RewriteCond %{REQUEST_URI} \/formpage\/?
RewriteCond %{QUERY_STRING} ^(.*)(&|\?)[a-z-_]+=(?=&|$)(.*)$ [NC]
RewriteRule .* \/TEST/formpage?%1%2 [R,L,NE]
0 Answers
Related