LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices

Reply
 
Search this Thread
Old 10-26-2006, 10:48 AM   #1
deesto
Member
 
Registered: May 2002
Location: NY, USA
Distribution: FreeBSD, Fedora, RHEL, Ubuntu; OS X, Win; have used Slackware, Mandrake, SuSE, Xandros
Posts: 448

Rep: Reputation: 31
Question apache rewrite help


I'm trying to proxy a server and change the appearance of the server directories for client browsers.

On the proxy server ("proxy"), I've added the following:
Code:
ReWriteEngine On
RewriteRule  ^/dir/ect/ory/$ http://server/directory/ [R]
This works in general, but the browser displays proxy/directory/ instead of proxy/dir/ect/ory/, which is what I would like it to show (is that a transparent proxy?).

I've also had to write additional rules for subdirectories, which tells me I'm probably doing something wrong:

Code:
RewriteRule  ^/dir/ect/ory/subdir$ http://server/directory/subdir [R]
To further complicate things, it doesn't work properly unless I include a ProxyPass directive:
Code:
ProxyPass /directory http://server/directory
ProxyPassReverse /directory http://server/directory
Any thoughts on what I'm doing wrong?

Last edited by deesto; 10-26-2006 at 01:34 PM.
 
Old 10-27-2006, 11:33 AM   #2
deesto
Member
 
Registered: May 2002
Location: NY, USA
Distribution: FreeBSD, Fedora, RHEL, Ubuntu; OS X, Win; have used Slackware, Mandrake, SuSE, Xandros
Posts: 448

Original Poster
Rep: Reputation: 31
I think a very simple pair of ProxyPass|ProxyPassReverse directives could replace some of this stuff, but not all... what about this on the proxy server:
Code:
ProxyPass /dir/ect/ory http://server/directory
ProxyPassReverse /dir/ect/ory http://server/directory
That seems to do exactly what I need as far as the client-side URL goes.

The problem is the subdirs: I'm doing this because I need to mirror TWiki pages (which are not .HTML files) with their HTML counterparts. The TWiki treats URL space a bit differently (their "webs" and "topics" appear as directories without a trailing slash in the URL). So when you browse to a specific page of the TWiki, you don't append .html to the URL because it doesn't exist. However, it's there on the HTML mirror, and I need something to not ony append the .html suffix to each incoming request, but to be able to tell whether the request is looking for a file or a directory.

The RewriteRule above works for that, if I duplicate it so it appears with and without the trailing slash, and for each subdirectory (I'm sure there's a better way... I can't figure out the syntax to condense it all). But that doesn't help with the URL space issue that ProxyPass seems to help with.

Last edited by deesto; 10-27-2006 at 11:35 AM.
 
Old 10-31-2006, 08:24 AM   #3
deesto
Member
 
Registered: May 2002
Location: NY, USA
Distribution: FreeBSD, Fedora, RHEL, Ubuntu; OS X, Win; have used Slackware, Mandrake, SuSE, Xandros
Posts: 448

Original Poster
Rep: Reputation: 31
Folks, any ideas on how to get this working, or to improve the methods I've tried? I'd really appreciate your help.
 
Old 11-03-2006, 02:07 PM   #4
deesto
Member
 
Registered: May 2002
Location: NY, USA
Distribution: FreeBSD, Fedora, RHEL, Ubuntu; OS X, Win; have used Slackware, Mandrake, SuSE, Xandros
Posts: 448

Original Poster
Rep: Reputation: 31
Question

OK... can anyone help me figure out how to clean this up on the proxy's httpd.conf?
Code:
<VirtualHost *:80>
    ServerAdmin webmaster@webserver
    ServerName webserver
    ReWriteEngine On
    RewriteLogLevel 2
    RewriteRule  ^/dir/ect/ory/misc/(\w+)(/.*)$  /directory/$1/misc/$1$2 [P,L]
    RewriteRule  ^/dir/ect/ory/(\w+)/misc(/.*)$  /directory/$1/misc$2 [P,L]
    RewriteRule  ^/dir/ect/misc/(\w+)(/.*)$  /directory/$1/misc/$1$2 [P,L]
    RewriteRule  ^/dir/ect/(\w+)/misc(/.*)$  /directory/$1/misc$2 [P,L]
    RewriteRule  ^/dir/misc/(\w+)(/.*)$  /directory/$1/misc/$1$2 [P,L]
    RewriteRule  ^/dir/(\w+)/misc(/.*)$  /directory/$1/misc$2 [P,L]
    RewriteRule  ^/dir/ect/ory/(\w+)/(\w+).html$  /directory/$1/$2.html [P,L]
    RewriteRule  ^/dir/ect/ory/(\w+).html$  /directory/Main/$1.html [P,L]
    RewriteRule  ^/dir/ect/ory/(\w+)/(\w+)$  /directory/$1/$2.html [P,L]
    RewriteRule  ^/dir/ect/ory/(\w+)/?$  /directory/$1/WebHome.html [P,L]
    RewriteRule  ^/dir/ect/ory/?$  /directory/Main/WebHome.html [P,L]
    RewriteRule  ^/dir/ect/(\w+)/(\w+).html$  /directory/$1/$2.html [P,L]
    RewriteRule  ^/dir/ect/(\w+).html$  /directory/Main/$1.html [P,L]
    RewriteRule  ^/dir/ect/(\w+)/(\w+)$  /directory/$1/$2.html [P,L]
    RewriteRule  ^/dir/ect/(\w+)/?$  /directory/$1/WebHome.html [P,L]
    RewriteRule  ^/dir/ect/?$  /directory/Main/WebHome.html [P,L]
    RewriteRule  ^/dir/(\w+)/(\w+).html$  /directory/$1/$2.html [P,L]
    RewriteRule  ^/dir/(\w+).html$  /directory/Main/$1.html [P,L]
    RewriteRule  ^/dir/(\w+)/(\w+)$  /directory/$1/$2.html [P,L]
    RewriteRule  ^/dir/(\w+)/?$  /directory/$1/WebHome.html [P,L]
    RewriteRule  ^/dir/?$  /directory/Main/WebHome.html [P,L]
    ProxyPass /directory http://webserver/directory
    ProxyPassReverse /directory  http://webserver/directory
</VirtualHost>
It finds all the files and directories, but some of the redirects give screwy URLs, and there's probably a much more efficient way to do all this.

Thanks.
 
  


Reply

Tags
apache, proxy, proxypass, rewrite


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
apache url rewrite gallew Linux - Server 0 08-25-2006 03:54 AM
Apache rewrite question kinetik Linux - General 2 08-04-2006 09:16 AM
Need help with Apache rewrite kinetik Linux - General 6 05-19-2006 06:02 AM
apache mod rewrite Robert0380 Linux - Software 5 07-31-2003 04:42 PM
Apache rewrite question CrazyToon Linux - Software 3 06-17-2003 02:00 PM


All times are GMT -5. The time now is 01:37 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration