Solved

rewrite a subdomain to a path using Apache?

Posted on 2014-02-06
4
217 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:NeilT
  • 2
4 Comments
 
LVL 82

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 82

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:NeilT
ID: 39857132
Many thanks , spot on
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

As Wikipedia explains 'robots.txt' as -- the robot exclusion standard, also known as the Robots Exclusion Protocol or robots.txt protocol, is a convention to prevent cooperating web spiders and other web robots from accessing all or part of a websit…
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…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

762 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

19 Experts available now in Live!

Get 1:1 Help Now