logo
Apache Lounge
Webmasters

 

About Forum Index Downloads Search Register Log in RSS X


Keep Server Online

If you find the Apache Lounge, the downloads and overall help useful, please express your satisfaction with a donation.

or

Bitcoin

A donation makes a contribution towards the costs, the time and effort that's going in this site and building.

Thank You! Steffen

Your donations will help to keep this site alive and well, and continuing building binaries. Apache Lounge is not sponsored.
Post new topic   Forum Index -> Apache View previous topic :: View next topic
Reply to topic   Topic: RewriteCond question
Author
edwardsmarkf



Joined: 20 Feb 2013
Posts: 27
Location: cottonwood, az

PostPosted: Fri 20 Mar '26 5:20    Post subject: RewriteCond question Reply with quote

hi all -

i have a situation where i have 10's of thousands of media files. Unfortunately, the sub-directory names are email addresses, and i need to BLOCK all access if a request does NOT contain the media name, like "file.mp3"
the directory is structured like this:


Quote:
/mainDir/email-1@google.com/email-2@google.com/file.mp3
/mainDir/email-1@google.com/email-3@google.com/file1.mp3
/mainDir/email-1@google.com/email-4@google.com/file2.mp3
/mainDir/email-5@google.com/email-6@google.com/file3.mp3
/mainDir/email-5@google.com/email-7@google.com/file4.mp3
/mainDir/email-5@google.com/email-8@google.com/file5.mp3
/mainDirA/mainDirB/e-9@google.com/e-10.google.com/xx.mp3
/mainDirA/mainDirB/e-11@google.com/e-12.google.com/yy.mp3


so if i saw a request that looks like any of the following (notice missing the mp3 file name):
Quote:
https://mydomain.com/mainDir/mainDir/email-1@google.com/
https://mydomain.com/mainDir/
https://mydomain.com/mainDir/email-1@google.com/email-2@google.com/
https://mydomain.com/mainDirA/MainDirB/

these need to be blocked.   currently i have a blank 'index.html' file in every directory, but this seems clumsy at best.

i am thinking a mod_rewrite that looks something like this:

Code:
RewriteCond /mainDir/ [OR]
RewriteCond /mainDirA/mainDirB/
RewriteRule !"\.mp3" "-" [F]


is this adequate?  or should i use something like these?

Code:

RewriteCond %{REQUEST_FILENAME}  -d
RewriteCond %{REQUEST_FILENAME}   !-f


its been a LONG time since i have used any mod_rewrite stuff and have forgotten most of it, sorry to say.
Back to top


Reply to topic   Topic: RewriteCond question View previous topic :: View next topic
Post new topic   Forum Index -> Apache