I’m looking for the code for .htaccess that will ignore certain characters of a file.
For example.
I have a file on my server, named file.txt, a link on the web goes to my file but the link is http://www.myserver.com/file12345.txt
I’m looking for the command that will rewrite incoming links and ignore all characters after the first 4 (file) no matter how many characters proceed the file.
Any ideas?
Try adding this to the htaccess file in your document root:
The first condition makes sure the request has 4 characters, then at least 1 other character that isn’t a
., then a.and an extension that is at least 2 characters. The next condition checks to make sure that if the stuff removed after the first 4 characters actually points to a file. If so, the internal rewrite takes place. If you want to actually redirect the browser, add aRflag into the square brackets.