: If you're know the exact format of each URL that you need, then it's pretty straight forward. If you don't know which extension you need to match though, well, then I'm fairly sure that's
If you're know the exact format of each URL that you need, then it's pretty straight forward. If you don't know which extension you need to match though, well, then I'm fairly sure that's impossible.
For example, if you KNOW that you have foo.html and bar.php - and that /foo/ needs to match foo.html and you KNOW that /bar/ needs to match /bar.php, then that can be done. But, if someone uploads /cat.php and someone enters /cat/ - the system will not know whether it needs to match /cat.html or /cat.php - you need to tell it. If you were just dealing with one extension, that wouldn't be so bad, you could just tack it onto every request.
To rewrite /foo/ to /foo.html then you would do:
RewriteRule (/foo/) /foo.html
Easy
If you want to match every request to a SINGLE extension, then you could do:
RewriteRule (/foo/)(.*)(/) /foo/.html
This will map /foo/mypage/ to /foo/mypage.html (and you can expand this to multi-level directory using some RegEx-fu that is above my pay grade).
Now, I don't actually know that that's what you're asking for, so please comment on my answer, or update your question, if these rules are not going to work for you.
-- Edit --
Just noticed your response to my comment above. There is no way you can do what you want to do with .htaccess, because .htaccess does not have the ability to check to see if a particular file requests exists. How will it know that /foo/ is meant to be /foo.html or /foo.php or /foo.cgi? Your only way around it will be to:
1) Funnel EVERY request through a single.php file that then has the ability to know/check to see if the .php or .html or .cgi version of the file exists, and then forwards your request that way
2) Create a .htaccess file that contains an entry for every single unique file
More posts by @Murphy175
Terms of Use Create Support ticket Your support tickets Stock Market News! © vmapp.org2024 All Rights reserved.