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 ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
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/ |