Jump to content

RewriteCond {REQUEST_URI}


son

Recommended Posts

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

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

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...