Apache mod_rewrite rule assistance


Hopefully, this will be simple.

I have a set of conditions requiring me to create an apache mod_rewrite rule to check for certain conditions, and if they are met, to redirect to a different port.

I need to basically rewrite any and all requests for any images (gif, jpg, png,) CSS, htm or html, to a port other than 80.

I've tried several different combinations of rewrite and redirect rules, but not having much luck.  I really need to break down and actually learn the rewrite engine.

Here's what I've tried so far.  (Please feel free to laugh!)

ReWriteCond %{SERVER_PORT} !^181$
RewriteCond %{REQUEST_URI} ^\.(gif|jpg|png)$
RewriteRule ^(.*)$ http://www.pickleberrypop.com:181/$1 [R,L]

ReWriteCond %{SERVER_PORT} !^181$
RewriteRule "^/(.*)\.(jpg|gif|png)$" "http://www.pickleberrypop.com:181/$1.$2" [L]

RedirectMatch perm ^/(.+)\.(gif|jpg|png)$ http://www.pickleberrypop.com:181/$1
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Sorry to inform, there's nothin to laugh at.
The first is almost there, should read(too many ^)
 RewriteCond %{SERVER_PORT} !=181
 RewriteCond %{REQUEST_URI} \.(gif|jpg|png)$
 RewriteRule (.*) http://www.pickleberrypop.com:181/$1 [R,L]

The second one is spoiled with "
 RewriteCond %{SERVER_PORT} !=181
 RewriteRule ^(.*)\.(jpg|gif|png)$ http://www.pickleberrypop.com:181/$1.$2 [R,L]

And the redirect should do as well
RedirectMatch perm /(.+)\.(gif|jpg|png)$ http://www.pickleberrypop.com:181/$1.$2

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
eoh-jasonAuthor Commented:
I was soo close.  Thanks for not laughing, and thanks for the help!  Works great now!
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Apache Web Server

From novice to tech pro — start learning today.