Forum Moderators: phranque

Message Too Old, No Replies

mod_rewrite to another server

         

kea12345

1:22 am on Sep 8, 2005 (gmt 0)

10+ Year Member



I am having a tough time with this, thought I would float it out to you all.

I am trying to redirect to link my existing image links to an image server.

such that

http://example.com/1/2/1.jpg will pull images from
[images.example.net...]

This is what I have:

Options +FollowSymlinks
RewriteEngine on
RewriteBase /images
RewriteRule ^/(.*)/(.*)\(.*)\.jpg?$ [images.example.net...] [R=301,L]

This does not seem to work and I do not get any error messages either.

Any suggestions?

[edited by: jdMorgan at 4:16 am (utc) on Sep. 8, 2005]
[edit reason] Examplified. [/edit]

jdMorgan

4:15 am on Sep 8, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Is this code in .htaccess or httpd.conf?

Why do you have a RewriteBase defined -- It's not obvious from your example URLs why you'd need it.

Jim

kea12345

8:05 pm on Sep 8, 2005 (gmt 0)

10+ Year Member



This is in .htaccess.

I thought you always had to have a base defined unless you were rewiting from the main directory.

ChadSEO

8:47 pm on Sep 8, 2005 (gmt 0)

10+ Year Member



kea12345,

RewriteBase is used when the virtual directory structure of your site doesn't match up to the physical directory structure on the server. Since you are redirecting to another server, this is a moot point, so you don't need it in there.

In an .htaccess file, the / at the beginning is automatically stripped off, so you don't need it. I also made a few changes to make it more efficient. At the end of your Rule, you had "jpg?$"; the question mark would make it match either jp or jpg. Not sure if that's what you had it mind - I took it out, but feel free to add it back in if that's what you wanted.

RewriteRule ^([^/]+)/([^/]+)/([^.]+)\.jpg$ [images.example.net...] [R=301,L]

Chad

kea12345

10:40 pm on Sep 8, 2005 (gmt 0)

10+ Year Member



Thanks soooo much.

I can stop pulling my hair out now.

jdMorgan

1:17 am on Sep 9, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Pretty code. :)

Jim