I have tried a ton of solutions posted at stackoverflow but nothing seems to work for me. I would like to rewrite a few URLs on my site to be search engine friendly.
UPDATED
Now is tested. Try this:
RewriteEngine On
RewriteRule ^([a-zA-Z0-9-=_?]+)/?$ index.php?filter=$1 [L]
.htaccess goes in root directory.
The requested URL is http://www.mysite.com/accounts/ but could be anything: http://www.mysite.com/apples/.
NOTE: The URL displayed in the address bar is the one that was entered in that address bar. I assume is not http://www.mysite.com/index.php?filter=accounts because I guess the purpose of the redirection is to replace it with a more friendly one (http://www.mysite.com/accounts), which is the one that has to be typed in the address bar, not the other way around. Little confusing but I hope it makes sense.
To test it, include the following only code at index.php in root directory.
<?php
if ($_GET['filter'] == 'accounts') {
echo "This is Accounts<br /><br />";
}else {
echo "This is INDEX<br /><br />";
}
?>
As to where to place the rewrite rules inside .htaccess, I could not know. I guess you have to try it before and after the actual rules.