http://example.com/bills.php?sort=highest
http://example.com/bills.php?sort=alpha
http://example.com/bills.php?sort=lowest
So the urls aboves sort by highest, alphabetical and lowest. They use the $_GET method with the use of a form. I was wondering if there was a way to submit the form/get the $_GET data without changing the url?
<form action="bills.php" method="get">
<select onchange="this.form.submit();" name="sort" class="right sort">
<option>What would you like to sort by?</option>
<option value="highest" <?php if(isset($_GET['sort']) && $_GET['sort'] == 'highest'){?> selected="selected" <?php } ?>>Highest to Lowest</option>
<option value="lowest" <?php if(isset($_GET['sort'])&& $_GET['sort'] == 'lowest'){?> selected="selected" <?php } ?>>Lowest to Highest</option>
<option value="alpha" <?php if(isset($_GET['sort'])&& $_GET['sort'] == 'alpha'){?> selected="selected" <?php } ?>>Alphabetically</option>
</select>
</form>
Above is the code in which I am able to submit a new sort request.
I would like to make my url stay at example.com/bills.php
would that be possible?
Would this be possible rewriting the url using .htaccess? I have tried a URL rewriting method which allows me to visit http://example.com/bills/alpha
and it works fine, but when I select a new query, it turns into http://example.com/bills/bills/?sort=alpha
.
Here's my .htaccess
RewriteEngine On
RewriteBase /
RewriteRule ^bills/(.*)$ /bills.php?id=$1