I'm working on a linking system that requires use of virtual directories. I've managed to set a system up that allows users to visit domain.com/SjkpP/ which gives the same effect as domain.com/link.php?link=SjkpP although the trailing slash is necessary and when a visiting domain.com/SjkpP a 404 error occurs. I'm pretty bad as for editing and adding to htaccess files so I was wondering what could I add to allow visiting the link without a trailing slash to work?
RewriteRule ([A-Za-z0-9]+)/ link.php?link=$1
If you want to make the trailing slash optional, you can use this instead:
RewriteRule ^([A-Za-z0-9]+)/?$ link.php?link=$1
This makes the final slash optional (with the regex
? zero-or-one match quantifier) but does not capture the slash if it does appear (because the slash appears outside the parentheses which capture the virtual directory name).