Your question is still a little vague as to what exactly you expect to have happen, but since you've posted your .htaccess
, I'll take a stab at it and see if I get what you were after.
The most obvious reason that your RewriteRule
isn't working is that your test pattern doesn't match the URL you've provided as an example, as your RewriteRule
requires a trailing slash (and only matches one character before that). Additionally, if you put it after the rules that you currently have in your .htaccess
file, it will never match because the request will have already been rewritten to index.php
.
I think that you want something like this...
Options +FollowSymlinks
RewriteEngine on
RewriteCond %{HTTP_HOST} =www.example.com [NC]
RewriteRule ^.*$ http://example.com/$0 [L,R=301]
# Make sure we end and force the redirect so %{REQUEST_FILENAME} gets changed
RewriteRule ^[a-zA-Z0-9-_+^/]+$ search_results/?action=search&username[equal]=$0 [L]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule .* index.php
However, if the search_results/
directory doesn't exist, then this is just going to be rewritten to index.php
anyway, so I'm not sure what the purpose of the redirection would be in that case. And, if it does exist, since your test pattern matches pretty much anything I'd expect to see in a site path, then everything will be rewritten to the search_results/
directory, so very little (if anything) will end up at your site root's index.php
.
Based on that, I feel like maybe there's some other criteria that you may have left out, but I could be wrong.