Solved

rewrite a subdomain to a path using Apache?

Posted on 2014-02-06
4
219 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 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:NeilT
ID: 39857132
Many thanks , spot on
0

Featured Post

Control application downtime with dependency maps

Visualize the interdependencies between application components better with Applications Manager's automated application discovery and dependency mapping feature. Resolve performance issues faster by quickly isolating problematic components.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
CentOS 7 (Apache2) Cannot Install SSL Cert 1 51
instanceof  operator in java 26 86
Problem to get function 52 100
Apache Issues 9 66
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…
If you've heard about htaccess and it sounds like it does what you want, but you're not sure how it works... well, you're in the right place. Read on. Some Basics #1. It's a file and its filename is .htaccess (yes, with a dot in the front). #…
A short film showing how OnPage and Connectwise integration works.
A company’s greatest vulnerability is their email. CEO fraud, ransomware and spear phishing attacks are the no1 threat to a company’s security. Cybercrime is responsible for the largest loss of money to companies today with losses projected to r…

919 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

20 Experts available now in Live!

Get 1:1 Help Now