[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Rewrite rule

Posted on 2011-09-30
1
Medium Priority
?
333 Views
Last Modified: 2012-06-21
A previous web developer decided ot redirect all domain.com URLs to www.domain.com. Now, we need to have a subdomain called members.domain.com and forums.domain.com, but that won't work because of the way the rewire rule is written. Further, I cannot change the rewrite rule, because it will break SEO.

I need to specifically allow members.domain.com and forums.domain.com (i.e., the rewrite rule should ignore those subdomains, but re-direct everything else).

How do I re-write that?

Here's the .htaccess file we're working with:

 
RewriteCond %{HTTP_HOST} !^www\.domain\.com$ [NC]
RewriteRule .? http://www.domain.com%{REQUEST_URI} [R=301,L]

Open in new window

0
Comment
Question by:DrDamnit
1 Comment
 
LVL 32

Accepted Solution

by:
DrDamnit earned 0 total points
ID: 36892981
Figured it out:
 
RewriteCond %{HTTP_HOST} !^www\.domain\.com$ [NC] [AND]
RewriteCond %{HTTP_HOST} !^forums\.domain\.com$ [NC] [AND]
RewriteCond %{HTTP_HOST} !^members\.domain\.com$ [NC]
RewriteRule .? http://www.domain.com%{REQUEST_URI} [R=301,L]

Open in new window

0

Featured Post

Nothing ever in the clear!

This technical paper will help you implement VMware’s VM encryption as well as implement Veeam encryption which together will achieve the nothing ever in the clear goal. If a bad guy steals VMs, backups or traffic they get nothing.

Question has a verified solution.

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

Over the last year I have answered a couple of basic URL rewriting questions several times so I thought I might as well have a stab at: explaining the basics, providing a few useful links and consolidating some of the most common queries into a sing…
If you are a web developer, you would be aware of the <iframe> tag in HTML. The <iframe> stands for inline frame and is used to embed another document within the current HTML document. The embedded document could be even another website.
This Micro Tutorial will teach you how to add a cinematic look to any film or video out there. There are very few simple steps that you will follow to do so. This will be demonstrated using Adobe Premiere Pro CS6.
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
Suggested Courses
Course of the Month18 days, 5 hours left to enroll

830 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