Solved

Apache rewrite rule help needed!

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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

In Solr 4.0 it is possible to atomically (or partially) update individual fields in a document. This article will show the operations possible for atomic updating as well as setting up your Solr instance to be able to perform the actions. One major …
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.
Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…
Hi friends,  in this video  I'll show you how new windows 10 user can learn the using of windows 10. Thank you.

910 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

24 Experts available now in Live!

Get 1:1 Help Now