?
Solved

Apache rewrite rule help needed!

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

Expert Comment

by:rhickmott
ID: 17989591
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
ID: 17991382
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 2000 total points
ID: 17994622
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
ID: 18000320
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

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

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

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…
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
Integration Management Part 2
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Suggested Courses
Course of the Month15 days, 6 hours left to enroll

840 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