mod_rewrite usage in mixed OS environment

mod_rewrite usage in mixed OS environment

am 23.08.2007 03:20:40 von scott.kesler

If this is not the correct group for this question, please point me to
the appropriate place. I am new to Apache as well, so please forgive
stupid queries/questions.

My company currently has about 70 web sites that are served by Apache
running on Xserve (OS X 10.4+). (BTW - We have recently migrated off
of IIS 6 on W2K3) This web server connects to 4 CDA JBoss servers
(also Xserve) which connect to a Linux Oracle DB server. The web
server sees the website content via a mapped drive that resides on a
Windows 2K3 server.

The problem is that the 70 websites are changing domain names and
moving file locations quite often (due to different company
departments). This is a problem and we are working on the process to
fix it, but in the mean time we need a work around.

The mod_rewrite module seems like the solution, but from all of the
research I've done, the mod_rewrite module looks for a .htaccess
file. This file should be placed in the root of the web site. In our
case, the web site content is on a Windows server so we cannot place
the .htaccess file in any web site root directory because a filename
beginning with a '.' is not allowed in Windows.

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

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

Any help is greatly appreciated.

Thanks,

Keslux
skesler at comcast.net

Re: mod_rewrite usage in mixed OS environment

am 23.08.2007 08:47:00 von unknown

Post removed (X-No-Archive: yes)

Re: mod_rewrite usage in mixed OS environment

am 23.08.2007 08:55:44 von HansH

schreef in bericht
news:1187832040.563738.23050@i38g2000prf.googlegroups.com...
> My company currently has about 70 web sites that are served by Apache
> running on Xserve (OS X 10.4+). (BTW - We have recently migrated off
> of IIS 6 on W2K3) This web server connects to 4 CDA JBoss servers
> (also Xserve) which connect to a Linux Oracle DB server. The web
> server sees the website content via a mapped drive that resides on a
> Windows 2K3 server.

> The mod_rewrite module seems like the solution, but from all of the
> research I've done, the mod_rewrite module looks for a .htaccess
> file.
To be a little more precise Apache looks for a .htaccess in each folder down
the path towards the file to be served. Any .htacces may contain directives
to be processed by mod_rewrite.

> This file should be placed in the root of the web site.
..htaccess can be placed in any folder

> In our case, the web site content is on a Windows server so we cannot
> place the .htaccess file in any web site root directory because a filename
> beginning with a '.' is not allowed in Windows.
Some GUI tools on Windows dislike an assumed nameless file
Just create the file using a CMDwindows en edit ...

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

> or something similar?
Though you can use the same directives in the main config or per stie.

> 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
I don't like cros domain images ...

This is a full external redirect. More common use of mod_rewrite is to
'only' modifiing the mapping of an URL to a local file.

Assuming www.foo.com will share all images at www.bar.com, consider using an
alias directory1 ../bar/pictures/
in the config of www.foo
or use a junction point at Windows to show _without_copying_ the content of
../foo/directory1/ at ./bar/images1 too
http://support.microsoft.com/kb/205524


HansH

Re: mod_rewrite usage in mixed OS environment

am 13.09.2007 06:59:24 von sean dreilinger

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:


ProxyRequests Off

Order deny,allow
Allow from all

ProxyPass /directory1 http://www.bar.com/directory1
ProxyPassReverse /directory1 http://www.bar.com/directory1


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


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


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


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



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

hth

--sean

--
sean dreilinger - http://durak.org/sean/