homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Visit PubCon.com
Home / Forums Index / Code, Content, and Presentation / Apache Web Server
Forum Library, Charter, Moderators: Ocean10000 & incrediBILL & phranque

Apache Web Server Forum

mod rewrite to proxy

 6:29 pm on Oct 24, 2013 (gmt 0)

Hi, I'm new to mod_rewrite and I need to setup a proxy on my clients server.

What we need is to inspect the requested URL and proxy the request to outside server. The returned content should appear to the browser as coming from our domain.

The URL calls are dynamic and we don't to control the full URL only the domain and the first directory in the request. The rest will be dynamic.

example request:


needs to proxy to:


I need to catch and proxy any request that starts with this URL: https://www.mysite.com/videothumb/ while maintaining the rest of the path/file/params.

I tried to add this to the httpd-vhosts.conf at the end of the <VirtualHost> section with no luck

RewriteRule ^videothumb/(.*)$ http://www.othercomp.com/$1 [P]

Any ideas how to accomplish this?

Thank you for your help



 7:59 pm on Oct 24, 2013 (gmt 0)

I tried to add this to the httpd-vhosts.conf at the end of the <VirtualHost> section with no luck

RewriteRule ^videothumb/

Is this rule inside a directory section? If not, it would need a leading slash. For insurance, try it without the opening anchor.

I'm assuming you have other RewriteRules in the same section, so the RewriteEngine is already on.

Does "no luck" mean that, as far as you can tell, nothing happened at all? Or did the wrong thing happen?


 8:15 pm on Oct 24, 2013 (gmt 0)

Thank you for the reply, yes there are other rules before this one and working fine. By nothing happens, I mean the proxy is not taking place and the request results in 404.

You mean try it like this:

RewriteRule /videothumb/(.*)$ http://www.othercomp.com/$1 [P]
RewriteRule videothumb/(.*)$ http://www.othercomp.com/$1 [P]


 4:00 am on Oct 25, 2013 (gmt 0)

A form with neither an anchor nor a slash will always work everywhere. So try that first. If pattern format isn't the problem, we'll dig deeper.

Can we also assume that mod_proxy is enabled? It would be a pretty embarrassing oversight-- but you wouldn't be the first!


 12:16 pm on Oct 26, 2013 (gmt 0)

yes its is on :) first thing I confirmed.

RewriteEngine on

I tried

RewriteRule ^videothumb/(.*)$ http://www.othercomp.com/$1 [P]
RewriteRule /videothumb/(.*)$ http://www.othercomp.com/$1 [P]
RewriteRule videothumb/(.*)$ http://www.othercomp.com/$1 [P]

with no luck. Yes, I did restart apache after each change.

I'm not clear if I need ProxyPassReverse as well?


 9:28 pm on Oct 26, 2013 (gmt 0)

While waiting for someone who speaks Apache:

Are you on 2.2 or 2.4? The present thread doesn't seem to say, and it may end up making a difference.


 1:14 am on Oct 27, 2013 (gmt 0)

The following 4 messages were cut out to new thread by incredibill. New thread at: apache/4619305.htm [webmasterworld.com]
10:46 pm on Oct 26, 2013 (PST -8)

Global Options:
 top home search open messages active posts  

Home / Forums Index / Code, Content, and Presentation / Apache Web Server
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved