son Posted September 6, 2011 Share Posted September 6, 2011 I have a mod rewrite for index file in directory working now as Options +FollowSymlinksRewriteEngine OnRewriteCond {REQUEST_URI} !^/photos/index.phpRewriteRule ^([A-Za-z0-9-]+)/?$ /files1/index.php?id=$1 [NC,L] The RewriteCond makes sure that the index.php in photos folder is not affected by the general re-write of any string consisting of numbers, letters or/and hyphens... However, in my photos folder there are a lot of files and it would be much better to somehow say that everything in folder would should be excluded. Also, there are two other folders with same exception. How can I add this?Thanks,Son Link to comment Share on other sites More sharing options...
Ingolme Posted September 6, 2011 Share Posted September 6, 2011 Most of the time we check that something is not a file and is not a directory: RewriteCond {REQUEST_FILENAME} !-fRewriteCond {REQUEST_FILENAME} !-d Link to comment Share on other sites More sharing options...
son Posted September 7, 2011 Author Share Posted September 7, 2011 But I would like to apply the rewrite only to the files1 directory, but not to the photos folder (or any files in it). So, in a way it is both a directory if you see what I mean. How would I do this? Son Link to comment Share on other sites More sharing options...
Ingolme Posted September 7, 2011 Share Posted September 7, 2011 You can add a condition ensuring that it's that directory: RewriteCond {REQUEST_FILENAME} ^/files1/.*RewriteCond {REQUEST_FILENAME} !-fRewriteCond {REQUEST_FILENAME} !-d The first condition tells the engine to only write if the file points to that directory. The second and third conditions tell it not to perform the rewrite if the request points to an existing file or directory. I'm not sure if this is exactly what you're intending. Link to comment Share on other sites More sharing options...
son Posted September 8, 2011 Author Share Posted September 8, 2011 Hi Ingolme,Thanks for your help. I simply cannot get it work and wondered if I could clarify one things first:REQUEST_FILENAME: this is what the user enters, isnt' it? For example www.domain.co.uk/var_name/index.php instead of www.domain.co.uk/files1/index.php?id=var_name.This is why I think I can only exclude the other directories. The querystring could hold any variable name, so I cannot anticipate what there is to come...Anyway, I want to exclude the folder and all files inside the folder 'photos'. Using:RewriteCond {REQUEST_FILENAME} !^/photos.*or RewriteCond {REQUEST_URI} !^/photos.*simply does not do it...Any ideas?Son Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.