Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Apache: Users

global mod_rewrite before virtualhosts

 

 

Apache users RSS feed   Index | Next | Previous | View Threaded


jgrant at vml

Oct 25, 2005, 3:04 PM

Post #1 of 4 (288 views)
Permalink
global mod_rewrite before virtualhosts

I am the admin for a server that is running over 150+ domains. Most of
the Domains uses Vignette to display the pages. Currently we are using
Sun One Web Server 6.1 to server the static files and use the weblogic
proxy to get the pages from Vignette. The way we have the proxy setup
is to pass all traffic starting with /app back to the weblogic server.

I am currently converting our Sun One Web Servers to Apache so that we
can use mod_rewrite to handle our redirect better along with allowing
for domain consolidation. Our goal with mod_rewrite is to be able to
only server /app/Colgate/US/* on www.colgate.com and server
/app/Colgate/FR/* on www.colgate.fr. This would mean that if someone
requested http://www.colgate.fr/app/Colgate/US/HomePage.cvsp I want to
have them redirect to
http://www.colgate.com/app/COlgate/US/HomePage.cvsp. I though I
understood mod_rewrite well enough to make this happen, and I can if I
add the entire rewrite rules to every VirtualHost but it does not seem
to work when I try to uses this globally.

I have my config files split out by domain with the line Include
/opt/www/conf/*.conf in my httpd.conf file. This does mean that I have
170 different config files.

Here is an example of what I am trying to use:

<VirtualHost _default_:80>
DocumentRoot /opt/VignetteRoot
ServerAlias www.colgate.com
RewriteRule ^/$ http://www.colgate.com/app/Colgate/US/HomePage.cvsp
[R=301]
<Location /app>
SetHandler weblogic-handler
WebLogicHost localprodapp1
WebLogicPort 7005
PathTrim /app
</Location>
</VirtualHost>

<VirtualHost *:80>
DocumentRoot /opt/VignetteRoot
ServeriName www.colgate.com
ServerAlias origin.www.colgate.com
ServerAlias colgate.com
ServerAlias globaltoolkit.colgate.com
ServerAlias colgatepalmolive.com
ServerAlias www.colgatepalmolive.com

RewriteEngine on
RewriteCond %{HTTP_HOST} ^colgate(|palmolive)\.com$
RewriteRule ^(.*) http://www.colgate.com$1 [R=301]

RewriteCond %{HTTP_HOST} ^globaltoolkit\.colgate\.com$
RewriteRule ^/$ /app/GlobalToolKit/US/HomePage.cvsp [PT]

RewriteCond %{HTTP_HOST} ^www\.colgate\.com$
RewriteRule ^/$ /edgescape/colgate.html [PT]
RewriteRule ^/espanol(|.*|/)
http://www.colgate.com/app/Colgate/USES/HomePage.cvsp [R=301]
RewriteRule ^/app/ColgateProfessional(.*)
http://www.colgateprofessional.com/app/ColgateProfessional$1 [R=301]
RewriteRule ^/maxfresh
http://www.colgate.com/app/MaxFresh/US/EN/HomePage.cvsp [R=301]
RewriteRule ^/app/Colgate/US/OralCare
http://www.colgate.com/app/Colgate/US/OC/HomePage.cvsp [R=301]
RewriteRule ^/app/Colgate/US/PersonalCare
http://www.colgate.com/app/Colgate/US/PC/HomePage.cvsp [R=301]

RewriteCond %{HTTP_HOST} ^sensitive\.colgate\.com$
RewriteRule ^(.*) http://www.colgatesensitive.com$1 [PT]

RewriteCond %{HTTP_HOST} ^sensitive-gr\.colgate\.com$
RewriteRule ^(.*) http://www.colgatesensitive.gr$1 [PT]

<Location /app>
SetHandler weblogic-handler
WebLogicHost localprodapp1
WebLogicPort 7005
PathTrim /app
</Location>
</VirtualHost>

RewriteEngine on
RewriteCond %{HTTP_HOST} !^www\.colgate\.com$ [OR]
RewriteCond %{REQUEST_URI} ^(/app/BrightSmilesBrightFutures/US)(.*)$
[OR]
RewriteCond %{REQUEST_URI} ^(/app/Colgate/US)(.*)$ [OR]
RewriteCond %{REQUEST_URI} ^(/app/Colgate/USES)(.*)$ [OR]
RewriteCond %{REQUEST_URI} ^(/app/Palmolive/US)(.*)$ [OR]
RewriteRule ^(.*)$ http://www.colgate.com$1 [L,R=301]


As you can see I have several Rewrite statements. Everything inside of
the <virtualHost> works as I expect. Though the rewrite at the end
outside of a <vitrualhost> does not seem to be called. I have even
tried pulling the rewrite out of the conf file for the domain redirects
to and place the redirects in their own config file that is Included
first from httpd.conf and then the *.conf for all *.conf my config files
and no change.

Is it possible to do what I am trying? Should I be trying to do this
another way?(RewriteMap)

Thanks for any help or direction anyone has to give.

Jeremy Grant
Unix System Specialist - Production Support
VML
VML Fact: "One of the 25 Best Companies to Work for in America."


---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe[at]httpd.apache.org
" from the digest: users-digest-unsubscribe[at]httpd.apache.org
For additional commands, e-mail: users-help[at]httpd.apache.org


jslive at gmail

Oct 25, 2005, 3:48 PM

Post #2 of 4 (292 views)
Permalink
Re: global mod_rewrite before virtualhosts [In reply to]

On 10/25/05, Jeremy Grant <jgrant[at]vml.com> wrote:
> I though I
> understood mod_rewrite well enough to make this happen, and I can if I
> add the entire rewrite rules to every VirtualHost but it does not seem
> to work when I try to uses this globally.

To have global rules apply to a <VirtualHost> you need to put
RewriteEngine On
RewriteOptions inherit
inside the <VirtualHost> section.

Silly, but true.

Joshua.

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe[at]httpd.apache.org
" from the digest: users-digest-unsubscribe[at]httpd.apache.org
For additional commands, e-mail: users-help[at]httpd.apache.org


Axel-Stephane.SMORGRAV at europe

Oct 26, 2005, 1:27 AM

Post #3 of 4 (296 views)
Permalink
RE: global mod_rewrite before virtualhosts [In reply to]

You may want to look into RewriteOptions Inherit (or something like that).

-ascs

-----Original Message-----
From: Jeremy Grant [mailto:jgrant[at]vml.com]
Sent: Wednesday, October 26, 2005 12:05 AM
To: users[at]httpd.apache.org
Subject: [users[at]httpd] global mod_rewrite before virtualhosts

I am the admin for a server that is running over 150+ domains. Most of the Domains uses Vignette to display the pages. Currently we are using Sun One Web Server 6.1 to server the static files and use the weblogic proxy to get the pages from Vignette. The way we have the proxy setup is to pass all traffic starting with /app back to the weblogic server.

I am currently converting our Sun One Web Servers to Apache so that we can use mod_rewrite to handle our redirect better along with allowing for domain consolidation. Our goal with mod_rewrite is to be able to only server /app/Colgate/US/* on www.colgate.com and server
/app/Colgate/FR/* on www.colgate.fr. This would mean that if someone requested http://www.colgate.fr/app/Colgate/US/HomePage.cvsp I want to have them redirect to http://www.colgate.com/app/COlgate/US/HomePage.cvsp. I though I understood mod_rewrite well enough to make this happen, and I can if I add the entire rewrite rules to every VirtualHost but it does not seem to work when I try to uses this globally.

I have my config files split out by domain with the line Include /opt/www/conf/*.conf in my httpd.conf file. This does mean that I have 170 different config files.

Here is an example of what I am trying to use:

<VirtualHost _default_:80>
DocumentRoot /opt/VignetteRoot
ServerAlias www.colgate.com
RewriteRule ^/$ http://www.colgate.com/app/Colgate/US/HomePage.cvsp
[R=301]
<Location /app>
SetHandler weblogic-handler
WebLogicHost localprodapp1
WebLogicPort 7005
PathTrim /app
</Location>
</VirtualHost>

<VirtualHost *:80>
DocumentRoot /opt/VignetteRoot
ServeriName www.colgate.com
ServerAlias origin.www.colgate.com
ServerAlias colgate.com
ServerAlias globaltoolkit.colgate.com
ServerAlias colgatepalmolive.com
ServerAlias www.colgatepalmolive.com

RewriteEngine on
RewriteCond %{HTTP_HOST} ^colgate(|palmolive)\.com$
RewriteRule ^(.*) http://www.colgate.com$1 [R=301]

RewriteCond %{HTTP_HOST} ^globaltoolkit\.colgate\.com$
RewriteRule ^/$ /app/GlobalToolKit/US/HomePage.cvsp [PT]

RewriteCond %{HTTP_HOST} ^www\.colgate\.com$
RewriteRule ^/$ /edgescape/colgate.html [PT]
RewriteRule ^/espanol(|.*|/)
http://www.colgate.com/app/Colgate/USES/HomePage.cvsp [R=301]
RewriteRule ^/app/ColgateProfessional(.*)
http://www.colgateprofessional.com/app/ColgateProfessional$1 [R=301]
RewriteRule ^/maxfresh
http://www.colgate.com/app/MaxFresh/US/EN/HomePage.cvsp [R=301]
RewriteRule ^/app/Colgate/US/OralCare http://www.colgate.com/app/Colgate/US/OC/HomePage.cvsp [R=301]
RewriteRule ^/app/Colgate/US/PersonalCare http://www.colgate.com/app/Colgate/US/PC/HomePage.cvsp [R=301]

RewriteCond %{HTTP_HOST} ^sensitive\.colgate\.com$
RewriteRule ^(.*) http://www.colgatesensitive.com$1 [PT]

RewriteCond %{HTTP_HOST} ^sensitive-gr\.colgate\.com$
RewriteRule ^(.*) http://www.colgatesensitive.gr$1 [PT]

<Location /app>
SetHandler weblogic-handler
WebLogicHost localprodapp1
WebLogicPort 7005
PathTrim /app
</Location>
</VirtualHost>

RewriteEngine on
RewriteCond %{HTTP_HOST} !^www\.colgate\.com$ [OR] RewriteCond %{REQUEST_URI} ^(/app/BrightSmilesBrightFutures/US)(.*)$
[OR]
RewriteCond %{REQUEST_URI} ^(/app/Colgate/US)(.*)$ [OR] RewriteCond %{REQUEST_URI} ^(/app/Colgate/USES)(.*)$ [OR] RewriteCond %{REQUEST_URI} ^(/app/Palmolive/US)(.*)$ [OR] RewriteRule ^(.*)$ http://www.colgate.com$1 [L,R=301]


As you can see I have several Rewrite statements. Everything inside of the <virtualHost> works as I expect. Though the rewrite at the end outside of a <vitrualhost> does not seem to be called. I have even tried pulling the rewrite out of the conf file for the domain redirects to and place the redirects in their own config file that is Included first from httpd.conf and then the *.conf for all *.conf my config files and no change.

Is it possible to do what I am trying? Should I be trying to do this another way?(RewriteMap)

Thanks for any help or direction anyone has to give.

Jeremy Grant
Unix System Specialist - Production Support VML VML Fact: "One of the 25 Best Companies to Work for in America."


---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe[at]httpd.apache.org
" from the digest: users-digest-unsubscribe[at]httpd.apache.org
For additional commands, e-mail: users-help[at]httpd.apache.org


---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe[at]httpd.apache.org
" from the digest: users-digest-unsubscribe[at]httpd.apache.org
For additional commands, e-mail: users-help[at]httpd.apache.org


jgrant at vml

Oct 26, 2005, 9:03 AM

Post #4 of 4 (288 views)
Permalink
RE: global mod_rewrite before virtualhosts [In reply to]

Thanks. That was my problem. Now I understand what that is for.

Jeremy Grant
VML
jgrant[at]vml.com
Desk: 816-218-3050

-----Original Message-----
From: Joshua Slive [mailto:jslive[at]gmail.com]
Sent: Tuesday, October 25, 2005 5:48 PM
To: users[at]httpd.apache.org
Subject: Re: [users[at]httpd] global mod_rewrite before virtualhosts

On 10/25/05, Jeremy Grant <jgrant[at]vml.com> wrote:
> I though I
> understood mod_rewrite well enough to make this happen, and I can if I
> add the entire rewrite rules to every VirtualHost but it does not seem
> to work when I try to uses this globally.

To have global rules apply to a <VirtualHost> you need to put
RewriteEngine On
RewriteOptions inherit
inside the <VirtualHost> section.

Silly, but true.

Joshua.

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server
Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe[at]httpd.apache.org
" from the digest: users-digest-unsubscribe[at]httpd.apache.org
For additional commands, e-mail: users-help[at]httpd.apache.org



---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe[at]httpd.apache.org
" from the digest: users-digest-unsubscribe[at]httpd.apache.org
For additional commands, e-mail: users-help[at]httpd.apache.org

Apache users RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact lists@gossamer-threads.com
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.