Solved

Redirect domain to URL Mapping

Posted on 2011-03-03
16
957 Views
Last Modified: 2012-05-11
I currently have a unix box where I have an HTTPServer that directs httprequests to a cluster of Portal servers which use IBM Portal Server 6.1.  On the Portal intances, I want to have some friendly URLs like this: www.mymainsite.com/wps/portal/MYSUBSITE  but I want to be able to make the "/wps/portal" disappear for the end user using a second domain name like this:  www.mysubsite.com

I was told that I can somehow redirect "www.mysubsite.com" to www.mymainsite.com/wps/portal/MYSUBSITE .  I have already added "www.mysubsite.com" to my Portal Plugin file to allow ports 80a nd 443 to pass to the portal but how do I redirect the URL in the httpd.conf file ?

Any ideas?
0
Comment
Question by:bganoush
  • 8
  • 8
16 Comments
 
LVL 31

Expert Comment

by:farzanj
Comment Utility
You can use iptables NAT option to use transparent Squid web proxy server
ptables -t nat -A PREROUTING -i eth0 -p tcp --dport 80 -j REDIRECT --to-port 3128

Open in new window



The Squid example are documented here:
http://wiki.squid-cache.org/ConfigExamples/Authenticate/Bypass
0
 

Author Comment

by:bganoush
Comment Utility

??
0
 
LVL 31

Expert Comment

by:farzanj
Comment Utility
Ok.

Try this

 
iptalbes -t nat -A PREROUTING -d www.mysubsite.com -p tcp --dport 80 -j DNAT --to www.mymainsite.com/wps/portal/MYSUBSITE

Open in new window

0
 
LVL 31

Expert Comment

by:farzanj
Comment Utility
Sorry, iptables no iptalbes
0
 

Author Comment

by:bganoush
Comment Utility

I don't know if I have access to the "squid" server, if we have one...   I have an HTTPServer and was hoping to modify the httpd.conf file using something like the "Rewrite" commands....

0
 
LVL 31

Expert Comment

by:farzanj
Comment Utility
In my second comment, I just told you to use iptables alone, no Squid.
0
 

Author Comment

by:bganoush
Comment Utility

where does that go? in teh httpd.conf file?
0
 
LVL 31

Expert Comment

by:farzanj
Comment Utility
It is firewall setting.

You have to type it up on the command line and then do this

service iptables save

The above command works for Redhat/CentOS.  For other flavors you will have to see who to save your iptables settings.
0
Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

 
LVL 31

Expert Comment

by:farzanj
Comment Utility
What kind of Linux are you using?  Could you make it to work?  Try doing man iptables and see options for saving iptables if you don't have Redhat/CentOS/Fedora
0
 

Author Comment

by:bganoush
Comment Utility

We are running everything from AIX ...  that's why I would prefer to modify the httpd.conf file instead, this solution would also be cross-platform.  I'm not sure if I can use your solution on all servers, especially windows...
0
 
LVL 31

Accepted Solution

by:
farzanj earned 500 total points
Comment Utility
Ok.  You can use .htaccess files.  Or if you want to modify the httpd.conf file here it goes.

Make sure the following module line is present and uncommented
LoadModule rewrite_module modules/mod_rewrite.so

Open in new window


Before we can rewrite, there is one option we must first set: FollowSymLinks. This is a security feature of the rewrite engine and you will not be able to rewrite without this option. In most cases, this will already be set in the server httpd.conf but you can safely state it again

The final requirement is to turn the rewrite engine on. I recommend you begin all your rewriting code with the following three lines, but you may not need the first two:

 
LoadModule rewrite_module modules/mod_rewrite.so

Open in new window


Then you can use RewriteRule  to change your URL.

Appears that you would need the following rule
RewriteRule www.mysubsite.com  www.mymainsite.com/wps/portal/MYSUBSITE
Options +FollowSymLinks
Options +Indexes
RewriteEngine On

Open in new window

0
 

Author Comment

by:bganoush
Comment Utility


So my final httpd file will contain something like this:


LoadModule rewrite_module modules/mod_rewrite.so
Options +FollowSymLinks
Options +Indexes
<VirtualHost *>
    RewriteEngine On
    RewriteRule www.mysubsite.com www.mymainsite.com/wps/portal/MYSUBSITE
</VirtualHost>

Open in new window

0
 

Author Comment

by:bganoush
Comment Utility

Does that make sense?
0
 
LVL 31

Expert Comment

by:farzanj
Comment Utility
Just uncomment line
LoadModule rewrite_module modules/mod_rewrite.so
it is there by default


You should have options in <Directory> or similar tag
For example:
 
<Directory /usr/local/httpd/htdocs>
Options +FollowSymLinks
Options +Indexes
</Directory>

Open in new window


Then test it and tell me whether it works or if not, what is the error or problem
0
 

Author Comment

by:bganoush
Comment Utility

Thanks.. I'm still working on this but I have been pulled away to another project until the end of this week.. I'll try what you said once i can get back on it.
0
 

Author Closing Comment

by:bganoush
Comment Utility
Thanks,

I went with a reverse proxy instead.
0

Featured Post

Backup Your Microsoft Windows Server®

Backup all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Join & Write a Comment

Suggested Solutions

This is a guide to setting up a new WHM/cPanel Server to be used for web hosting accounts. It is intended for web hosting company administrators and dedicated server owners. For under $99 per month (considering normal rate of Big Data Cetnters like …
When it comes to showing a 404 error page to your visitors, you do not want that generic page to show, and you especially do not want your hosting provider’s ad error page to show either. In this article, I will show you how to enable the custom 40…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now