I have a site hosted on Hostinger and was experimenting with RewriteRule in .htaccess, and here's what I ended up using:
RewriteEngine on
RewriteRule ^/(accounts)/[0-9]+[/]?$ /account?$2
I was hoping that this would redirect /accounts/[id] to /account?[id] but instead I get a 404. Any thoughts?
EDIT: I also did not mention that this is on a subdomain. Should htaccess be on the www document root and not the subdomain document root? Would be weird
You are only capturing only one group, and pasting $2, therefore this wont work... instead you should do:
RewriteRule ^(accounts)/([0-9]+)[/]?$ /account?$2 [R=301,L]
^ ^
But you can just capture one group:
RewriteRule ^accounts/([0-9]+)/?$ /account?id=$1 [R=301,L]