Forum Moderators: phranque

Message Too Old, No Replies

.htaccess and Flash Player problems with mod_rewrite

Need some help here...

         

nathanent

11:09 pm on Mar 29, 2006 (gmt 0)

10+ Year Member



I am using a .htaccess file to rewrite urls, so an artist can have their own url on my website. It works great (not at first), and it is all setup on test, but the I have a Flash player that plays their songs. The flash player shows up, but it won't play anything. When I remove the .htaccess file it works great. I'm new to messing with the .htaccess files, so let me know where I'm going wrong here:

RewriteEngine on
RewriteCond %{REQUEST_URI}!^/viewArtUrl\.php
RewriteCond %{REQUEST_URI}!\.jpg$
RewriteCond %{REQUEST_URI}!\.css$
RewriteCond %{REQUEST_URI}!\.gif$
RewriteCond %{REQUEST_URI}!\.swf$
RewriteCond %{REQUEST_URI}!\.inc$
RewriteCond %{REQUEST_URI}!\.html$
RewriteCond %{REQUEST_URI}!\.xml$
RewriteCond %{REQUEST_URI}!\.mp3$
RewriteRule ^([^/]+)/? viewArtUrl.php?siteurl=$1 [L]

Basically I had to add every file extension up there for anything to work , but I'm sure there is a way around all this right (referring to having to list every file extension found in the directory)? There are a lot of other file extensions I didn't add, because I'm sure there is a way around adding all of those. But basically when I didn't have .css$ listed, then that was broken. I KNOW there is a way around it, but I'm not hip to it. Thanks.

coopster

2:19 am on Apr 1, 2006 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Welcome to WebmasterWorld, nathanent.

I hesitate to move this thread to our Apache forum [webmasterworld.com] yet because it is very unclear where you are at and where you desire to be. Can you explain in more detail what you are attempting to accomplish? Is anything here PHP related?

nathanent

3:07 pm on Apr 1, 2006 (gmt 0)

10+ Year Member



I guess not actually. I thought it was PHP related at first, but it is pretty much straight apache. I figured it out, but I would still like to know WHY it acts that way. So sure, move it to the apache forum. sorry about that.

jdMorgan

3:52 pm on Apr 2, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



When creating a RewriteRule that applies to multiple URLs, you have to figure what URLs you do want to rewrite, and what URLs you don't want to rewrite. Then you have to figure out how to tell mod_rewrite. This can be done by rewriting a list of URLs, by NOT rewriting a list of URLs, or by a combination of those two approaches. If the list(s) get too long, then you can rewrite or not rewrite based on characteristics of the URLs; whether they contain a unique string or character set, whether the associated file exists, etc.

In your case, you are telling mod_rewrite NOT to rewrite a set of URLs, based on the file extension. You might be able to reduce the size and complexity of the code by telling it what *to* rewrite instead.

Once the URLs are analyzed and a concise way to identify whether they should be rewritten is identified, then coding is the easy part.

Take a look at the entire URL-space of your site, and figure out what URLs you do and don't want rewritten to viewArtUrl.php, and how to easily identify them. Then the rest is just a few lines of code.

Jim