Solved

Redirect domain to URL Mapping

Posted on 2011-03-03
16
960 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
ID: 35030083
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
ID: 35030121

??
0
 
LVL 31

Expert Comment

by:farzanj
ID: 35030155
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
Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

 
LVL 31

Expert Comment

by:farzanj
ID: 35030165
Sorry, iptables no iptalbes
0
 

Author Comment

by:bganoush
ID: 35030944

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
ID: 35031064
In my second comment, I just told you to use iptables alone, no Squid.
0
 

Author Comment

by:bganoush
ID: 35031084

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

Expert Comment

by:farzanj
ID: 35031114
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
 
LVL 31

Expert Comment

by:farzanj
ID: 35031176
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
ID: 35083022

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
ID: 35083936
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
ID: 35098894


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
ID: 35098897

Does that make sense?
0
 
LVL 31

Expert Comment

by:farzanj
ID: 35099461
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
ID: 35180707

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
ID: 36130962
Thanks,

I went with a reverse proxy instead.
0

Featured Post

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
site launch date and last modified date 3 93
Protectings Systems from Malicous Users 4 126
http to https 3 62
How code a 301 redirect for folder files -> 1 file 2 40
Introduction As you’re probably aware the HTTP protocol offers basic / weak authentication, which in combination with the relevant configuration on your web server, provides the ability to password protect all or part of your host.  If you were not…
If your site has a few sections that need to be secure when data is transmitted between the server and local computer, such as a /order/ section for ordering or /customer/ which contains customer data, etc it would of course be recommended to secure…
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

777 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