RE: [users@httpd] global mod_rewrite before virtualhosts

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

-ascs 

-----Original Message-----
From: Jeremy Grant [mailto:jgrant@xxxxxxx] 
Sent: Wednesday, October 26, 2005 12:05 AM
To: users@xxxxxxxxxxxxxxxx
Subject: [users@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@xxxxxxxxxxxxxxxx
   "   from the digest: users-digest-unsubscribe@xxxxxxxxxxxxxxxx
For additional commands, e-mail: users-help@xxxxxxxxxxxxxxxx


---------------------------------------------------------------------
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@xxxxxxxxxxxxxxxx
   "   from the digest: users-digest-unsubscribe@xxxxxxxxxxxxxxxx
For additional commands, e-mail: users-help@xxxxxxxxxxxxxxxx



[Index of Archives]     [Open SSH Users]     [Linux ACPI]     [Linux Kernel]     [Linux Laptop]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Squid]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]

  Powered by Linux