Re: mod_rewrite usage in mixed OS environment

This is a discussion on Re: mod_rewrite usage in mixed OS environment within the Apache Web Server forums, part of the Web Server and Related Forums category; scott.kesler@gmail.com wrote: if your internal file locations are shift around a lot, you can still offer a ...


Go Back   Usenet Forums > Web Server and Related Forums > Apache Web Server

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 09-13-2007
sean dreilinger
 
Posts: n/a
Default Re: mod_rewrite usage in mixed OS environment

scott.kesler@gmail.com wrote:

if your internal file locations are shift around a lot, you can still offer a
persistent url space to your customers by implementing a reverse-proxy -
customers continue to use the same urls, and you proxy the internal content from
wherever it happens to be living. if the content moves [again and again], you
just change the proxy configuration to point at the new content source
behind-the-scenes -- that way the customers and web search engines that have
bookmarked your content will not need to change their urls.

whether you choose to reverse-proxy or redirect, here are three potential
solutions for you...

> My question is... can the .htaccess file be placed anywhere else? Can
> a 'master' .htaccess file be created in /apache2/conf/ or something
> similar?


you can use the apache Include directive to embed just about any file on the
system into your configuration at server (re)start:

http://httpd.apache.org/docs/2.2/mod/core.html#include

to embed a bunch of mod_rewrite rules (or other configuration directives that
accomplish the same redirects), you could have this in your httpd.conf:

Include /path/to/conf/rewrite_rules.txt

and, based on your example:

> The end result I'm looking for is:
> Original URL:
> http://www.foo.com/directory1/picture.jpg
> Redirected to URL:
> http://www.bar.com/directory1/picture.jpg


the /path/to/conf/rewrite_rules.txt file could include any of these three
approaches to mapping the old addresses to the new content location:

==== rewrite_rules.txt ===

### use mod_proxy to proxy the relocated content
### without exposing any changes to the end-user:

<ifModule mod_proxy.c>
ProxyRequests Off
<Proxy *>
Order deny,allow
Allow from all
</Proxy>
ProxyPass /directory1 http://www.bar.com/directory1
ProxyPassReverse /directory1 http://www.bar.com/directory1
</IfModule>

### or...
### use apache mod_alias to handle the redirect

<ifModule mod_alias.c>
### redirect everything in /directory1 to directory1 on a different server:
RedirectMatch 301 ^/directory1/(.*) http://www.bar.com/directory1/$1
</ifModule>

### or...
### use mod_rewrite to handle the redirect

<ifModule mod_rewrite.c>
### redirect everything in /directory1 to directory1 on a different server:
RewriteEngine On
RewriteRule ^/directory1/(.*) http://www.bar.com/directory1/$1 [R=301,L]
</ifModule>


=== /end of rewrite_rules.txt ===

hth

--sean

--
sean dreilinger - http://durak.org/sean/
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 05:00 PM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0