Solved

Apache rewrite rule help needed!

Posted on 2006-11-21
4
279 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 500 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

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

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

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 …
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…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

770 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