Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How does one do a rewrite of a domain name?

Status
Not open for further replies.

langbeen

Programmer
Sep 29, 2003
3
GB
Hi,

Anyone's help much appreciated for the following problem.

THE SITUATION
We have multiple domain names resolving to a single IP address. In the Apache httpd.conf file (v 1.x) we point the incoming traffic for each domain to the relevant page using virtual hosts. This works fine, however at the moment it is set up such that the domain the user enters is always replaced by the main domain name - for example:

Say a user loads Our virtual host will rewrite the URL as follows:

<VirtualHost *>
DocumentRoot /export/home/docroot/
ServerName RewriteEngine On
RewriteRule ^/ </VirtualHost>

The user's browser will then reflect that he or she is at
What I want is for the user to end up on the same page, BUT with the original domain name, i.e.


I've tried

RewriteRule ^/ /web/init.jsp
and
RewriteRule ^/ web/init.jsp

But these don't work.


The set up of our default domain is something like this (we use a plug in to get Apache to talk to BroadVision...)

<VirtualHost _default_:80>
DocumentRoot /export/home/docroot
ServerName
BroadVision oe

<Location /web>
SetHandler bvsm-handler
Order deny,allow
Deny from xxx.xxx.xxx.xxx
Allow from all
</Location>
</VirtualHost>

Hope this makes sense - thanks in advance for any ideas!

Andy
 
When you try to work with the same URL space you will continually catch yourself and spin the server off.

example:
Base Domain might be
RewriteRule ^/ /web/init.jsp

This will redirect
to


But now this NEW REQUEST gets caught in the same rewrite rule and spins off forever..

This is why you usually see rewrite rules go to different servers.

You may need to write a RewriteCond rule that checks to make sure the domain is not ALREADY /web/init.jsp and if NOt then it redirects.

Something like :

RewriteCond %{REQUEST_URI} !^/web/.*$ [NC]
RewriteRule ^/ /web/init.jsp [R]
 
Thanks, Siberian, that seems to have worked perfectly!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top