adrianTNT Posted July 17, 2009 Share Posted July 17, 2009 Hello. I have the actual real directory structure like this: my_files/101/ my_files/102/ and I want to rewrite to cleaner URL like this: /101/ /102/ if there is an actual file index.html in the real folder my_files/101/index.html then I want that one shown at URL /101/ else I want it do display my script (generate_index.php). I was trying something like: RewriteCond %{REQUEST_FILENAME} -F RewriteRule ^([0-9]+)/$ my_files/$1/index.html [QSA] ... RewriteRule ^([0-9]+)/$ generate_index.php?$1[QSA] But I guess REQUEST_FILENAME and -F is wrong way to test if index.html exists. Which param and string I have to test? Quote Link to comment https://forums.phpfreaks.com/topic/166387-testing-if-a-file-exists-i-dont-know-which-param-to-use/ Share on other sites More sharing options...
lifetalk Posted July 26, 2009 Share Posted July 26, 2009 The RewriteCond REQUEST_FILENAME checks if the file exists. If it does not exist, it applies the rules. So basically, RewriteCond %{REQUEST_FILENAME} !-f Would 'tell' the server to check whether the index.html that is being requested is actually physically present on server. If it is not (the '!' is equal to 'not') the next line(s) of RewriteRules should be executed. Quote Link to comment https://forums.phpfreaks.com/topic/166387-testing-if-a-file-exists-i-dont-know-which-param-to-use/#findComment-883408 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.