Solved

rewrite a subdomain to a path using Apache?

Posted on 2014-02-06
4
222 Views
Last Modified: 2014-02-13
Hi

I've been asked if I can rewrite an address using Apache 2.2

I'm trying to get and of these
members|intranet|email to become the path after a preset domain, whatever http or https method used initially should also follow through

eg.

http://members.bbb.co.uk should re-write to http://www.bbb.co.uk/members
https://members.bbb.co.uk should re-write to https://www.bbb.co.uk/members

and so on

I think I need something like this but not really sure what I am doing here:
#RewriteRule ^(members|intranet|email)(?:/(.*))?$ https://aa.bbbbbbb.co.uk/$1 [P]

Thanks in advance
0
Comment
Question by:Neil Thompson
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 83

Expert Comment

by:Dave Baldwin
ID: 39839622
Don't you have that backwards?  The first item is what is seen in the browser and the second item is where it goes on the server.

http://www.bbb.co.uk/members should re-write to http://members.bbb.co.uk
https://www.bbb.co.uk/members should re-write to https://members.bbb.co.uk
0
 
LVL 83

Expert Comment

by:Dave Baldwin
ID: 39839640
On my site it looks like this.
RewriteEngine on  

RewriteCond %{HTTPS} !=on
RewriteRule ^members  http://members.bbb.co.uk/

RewriteCond %{HTTPS} =on
RewriteRule ^members  https://members.bbb.co.uk/

Open in new window

0
 
LVL 58

Accepted Solution

by:
Gary earned 500 total points
ID: 39839696
Try this
RewriteEngine on
RewriteCond %{HTTPS}:s (on:(s)|off:s)
RewriteCond %{HTTP_HOST} ^(email|members|internet)\. [NC]
RewriteRule (.*) http%1://www.site.com/%2 [R=301,L]

Open in new window

0
 
LVL 3

Author Closing Comment

by:Neil Thompson
ID: 39857132
Many thanks , spot on
0

Featured Post

Don't miss ATEN at NAB Show April 24-27!

Visit ATEN at NAB Show to learn how our "Seamlessly Entertaining" solutions deliver fast, precise video streaming without delays for the broadcasting and media environment. ATEN will showcase its 16x16 Modular Matrix Switch (VM1600) and KVM Over IP Solution (KE6900 series).

Question has a verified solution.

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

In my time as an SEO for the last 2 years and in the questions I have assisted with on here I have always seen the need to redirect from non-www urls to their www versions. For instance redirecting http://domain.com (http://domain.com) to http…
In Solr 4.0 it is possible to atomically (or partially) update individual fields in a document. This article will show the operations possible for atomic updating as well as setting up your Solr instance to be able to perform the actions. One major …
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

756 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