Solved

Apache rewrite rule help needed!

Posted on 2006-11-21
4
277 Views
Last Modified: 2010-03-04
0
Comment
Question by:894359
  • 2
  • 2
4 Comments
 
LVL 13

Expert Comment

by:rhickmott
Comment Utility
Try

RewriteEngine on
RewriteCond %{HTTP_HOST} !^www\.commandandconquer\.com/exclusive$ [NC]
RewriteRule ^(.*)$ http://www.ea.com/commandandconquer/$1 [R=301,L]
RewriteRule ^(.*)$ http://www.ea.com/commandandconquer/exclusive/$1 [R=301,L]
0
 

Author Comment

by:894359
Comment Utility
Doesn't work?  What is the precedence for vhosts and rewrites? What I need to do is have:

www.commandandconquer.com              
www.commandandconquer.ea.com          
commandandconquer.ea.com                
commandandconquer.com            

all point to :

http://www.ea.com/commandandconquer/


but the one special condition I have is that  www.commandandconquer.ea.com/exclusive goes to http://www.ea.com/commandandconquer/exclusive/

Not sure how to do this?

Currently vhosts contains:

www.commandandconquer.com               http://www.ea.com/commandandconquer/
www.commandandconquer.ea.com            http://www.ea.com/commandandconquer/
commandandconquer.ea.com                http://www.ea.com/commandandconquer/
commandandconquer.com                   http://www.ea.com/commandandconquer/

which I removed and tried adding this to the prod.conf file:

RewriteCond ${lowercase:%{SERVER_NAME}} ^(www.commandandconquer.ea.com)$ [OR]
RewriteCond ${lowercase:%{SERVER_NAME}} ^(commandandconquer.ea.com)$
RewriteRule ^(.*)$ http://www.ea.com/commandandconquer/$1 [R=301,L]

RewriteCond %{HTTP_HOST} !^www\.commandandconquer\.com/exclusive$ [NC]
RewriteRule ^(.*)$ http://www.ea.com/commandandconquer/exclusive/$1 [R=301,L]

But the exclusive piece never worked, everything went to http://www.ea.com/commandandconquer/
0
 
LVL 13

Accepted Solution

by:
rhickmott earned 500 total points
Comment Utility
It will run the first rule and if not executed it will move onto the first ( The L Flag ) I must apologise in there was a slight wrror in the first staatement it should have been

RewriteCond %{HTTP_HOST} !^www\.commandandconquer\.ea\.com/exclusive$ [NC]
(Note the .ea bit)


It Depends on where you are coming from assumingly all these domains are hosted on the one server an IP and your using VirtualHosts.

The ones that are straight redirects are easy you can do this in your VirtualHost contrainers.

<VirtualHost xxx.xxx.xxx.xxx:80> (or whatever your using)
       ServerName *.commandandconquer.com
       Redirect Permanent / http://www.ea.com/commandandconquer/
</VirtualHost>

<VirtualHost xxx.xxx.xxx.xxx:80> (or whatever your using)
       ServerName *.ea.com
       RewriteEngine on
       RewriteCond %{HTTP_HOST} !^.*\.commandandconquer\.ea\.com/exclusive$ [NC]
       RewriteRule ^(.*)$ http://www.ea.com/commandandconquer/$1 [R=301,L]
       RewriteRule ^(.*)$ http://www.ea.com/commandandconquer/exclusive/$1 [R=301,L]
</VirtualHost>


Basically this says if the user is NOT going to <anything>.commandandconquer.ea.com/exclusive kick them to http://www.ea.com/commandandconquer/ and stop processing more rules.

So if this rule is not run therefore it MUST be a request for the exclusive site so then it will direct them to http://www.ea.com/commandandconquer/exclusive/
0
 

Author Comment

by:894359
Comment Utility
RewriteCond ${lowercase:%{SERVER_NAME}} ^(www\.commandandconquer\.ea\.com)$ [OR]
RewriteCond ${lowercase:%{SERVER_NAME}} ^(commandandconquer\.ea\.com)$
RewriteRule ^/exclusive$ http://www.ea.com/commandandconquer/exclusive/ [L,R]
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Suggested Solutions

Hi, in this article I'm going to teach you how to run your own site, and how to let people in (without IP). I'll talk about and explain each step... :) By the way, everything in this Tutorial is completely free and legal. This article is for …
It is possible to boost certain documents at query time in Solr. Query time boosting can be a powerful resource for finding the most relevant and "best" content. Of course the more information you index, the more fields you will be able to use for y…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

744 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

16 Experts available now in Live!

Get 1:1 Help Now