Forum Moderators: phranque

Message Too Old, No Replies

exclude files from Wordpress rewrite

excluding files and directories in htaccess

         

venice

8:15 pm on Mar 16, 2007 (gmt 0)

10+ Year Member



I want to set up some directories on the root of a Wordpress web site that are excluded from the mod_rewrite rules that are currently in my .htaccess file.

I want to be able to upload MP3 files to two different directories and want users to be able to access those files via a link on my Wordpress site, or from applications such as Winamp or media player.

I'm having no problem accessing and playing .mp3 files via Winamp or media player but I get 404 errors when attempting to access a .mp3 file via the Wordpress site.

I can access the directories and I can view the MP3 files via a Web browser (I'm using Firefox 2.0.0.2) but I get the 404 error if I click on a file.

Ultimately, I'd like to be able to add these MP3 URLs to posts or incorporate them into the blogroll links on the Wordpress site.

here's what's in my .htaccess...

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} ^/fred/(.*)$ [OR]
RewriteCond %{REQUEST_URI} ^/susan/(.*)$
RewriteRule ^.*$ - [L]
</IfModule>
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME}!-f
RewriteCond %{REQUEST_FILENAME}!-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress

jdMorgan

12:33 am on Mar 17, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



One way to do it would be to use your existing exclusionary code:

RewriteCond %{REQUEST_URI} ^/path_to_mp3_files/ [OR]
RewriteCond %{REQUEST_URI} ^/fred/ [OR]
RewriteCond %{REQUEST_URI} ^/susan/
RewriteRule .* - [L]

Note the other cleanups and optimizations as well, none of which affect function, but may improve performance.

For more information, see the documents cited in our forum charter [webmasterworld.com] and the tutorials in the Apache forum section of the WebmasterWorld library [webmasterworld.com].

Jim