I need help with URL rewrite. I will like to make this URL (https://example.test/bet/r/?r=fad5v) look like this (https://example.test/bet/fad5v).
What's the best way to do this so that when https://example.test/bet/fad5v is visited, it opens the actual URL https://example.test/bet/r/?r=fad5v.
Any help will be appreciated.
Try the following near the top of your root
.htaccessfile:UPDATE: From comments, it seems you have been putting this directive in the
.htaccessin the/betsubdirectory (ie./bet/.htaccess), not the document root directory as mentioned above.If you are using the
/bet/.htaccessfile then you will need to modify the above directive(s) to read:It is advisable to make the regex as restrictive as possible so as not to conflict with other resources (eg. can this code only consist of lowercase a-z and digits?). You'll note that I've added the dot to the character class to avoid conflicting with actual files (as you noted in comments).