Paying for mod_rewrite/ subdomain issue

Discussion in 'Apache' started by tru504187211, Nov 9, 2007.

  1. #1
    Hello all,

    I need help with setting up this mod_rewrite function on my server. I have already setup and got the wildcard dns working, but here is the rest of the equation...


    http://www.domain.com/viewall.php?cat=1
    to
    http://subdomain1.domain.com/viewall.php


    ...and there would be more categories...

    http://www.domain.com/viewall.php?cat=2
    to
    http://subdomain2.domain.com/viewall.php

    http://www.domain.com/viewall.php?cat=3
    to
    http://subdomain3.domain.com/viewall.php


    Any ideas??? $10 via paypal to the first who can get this working for me...

    Thanks and good luck!
     
    tru504187211, Nov 9, 2007 IP
  2. AHA7

    AHA7 Peon

    Messages:
    445
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    0
    #2
    RewriteCond %{HTTP_HOST} ^www\.domain\.com
    RewriteCond %{REQUEST_URI} ^/viewall.php?cat=(.*)$ [NC]
    RewriteRule ^(.*)  http://subdomain$1.domain.com/viewall.php [R=301,L]
    Code (markup):
     
    AHA7, Nov 9, 2007 IP
  3. tru504187211

    tru504187211 Peon

    Messages:
    287
    Likes Received:
    15
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Thanks for the QUICK reply!

    Question though...OK, I am a complete n00b at mod_rewrite no matter how much I read about it....so how about I change it up a bit to make it exact to what I want...

    http://www.domain.com/viewall.php?cat=1
    to
    http://ford.domain.com/viewall.php


    http://www.domain.com/viewall.php?cat=2
    to
    http://chevy.domain.com/viewall.php


    http://www.domain.com/viewall.php?cat=3
    to
    http://toyota.domain.com/viewall.php


    Sorry, but I got confused about the subdomain$1 thinking it was a variable...AHA7 - the question is locked for you for a while if you are able to give me the correct code -- my fault, I should have been more specific...
     
    tru504187211, Nov 9, 2007 IP
  4. AHA7

    AHA7 Peon

    Messages:
    445
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    0
    #4
    In this case you'll have to write a condition and a rewrite rule for each subdomain. How many subdomains do you have?
     
    AHA7, Nov 9, 2007 IP
  5. AHA7

    AHA7 Peon

    Messages:
    445
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    0
    #5
    AHA7, Nov 9, 2007 IP
  6. tru504187211

    tru504187211 Peon

    Messages:
    287
    Likes Received:
    15
    Best Answers:
    0
    Trophy Points:
    0
    #6
    There are 8 'virtual' subdomains that I would like to have...I kind of figured on the 8 different case statements...
     
    tru504187211, Nov 9, 2007 IP
  7. tru504187211

    tru504187211 Peon

    Messages:
    287
    Likes Received:
    15
    Best Answers:
    0
    Trophy Points:
    0
  8. AHA7

    AHA7 Peon

    Messages:
    445
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    0
    #8
    Did you see my very last post above?
    If you'd like I can give you the 8 statements if you give me the subdomains.
     
    AHA7, Nov 9, 2007 IP
  9. tru504187211

    tru504187211 Peon

    Messages:
    287
    Likes Received:
    15
    Best Answers:
    0
    Trophy Points:
    0
    #9
    My categories are...

    Ford
    GM
    Chrysler
    Toyota
    Honda
    Acura
    Nissan
    Chevy

    ....Thanks!
     
    tru504187211, Nov 9, 2007 IP
  10. AHA7

    AHA7 Peon

    Messages:
    445
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    0
    #10
    RewriteCond %{HTTP_HOST} ^www\.domain\.com
    RewriteCond %{REQUEST_URI} ^/viewall.php?cat=1$ [NC]
    RewriteRule ^(.*)  http://Ford.domain.com/viewall.php [R=301,L]
    
    RewriteCond %{HTTP_HOST} ^www\.domain\.com
    RewriteCond %{REQUEST_URI} ^/viewall.php?cat=2$ [NC]
    RewriteRule ^(.*)  http://GM.domain.com/viewall.php [R=301,L]
    
    RewriteCond %{HTTP_HOST} ^www\.domain\.com
    RewriteCond %{REQUEST_URI} ^/viewall.php?cat=3$ [NC]
    RewriteRule ^(.*)  http://Chrysler.domain.com/viewall.php [R=301,L]
    
    RewriteCond %{HTTP_HOST} ^www\.domain\.com
    RewriteCond %{REQUEST_URI} ^/viewall.php?cat=4$ [NC]
    RewriteRule ^(.*)  http://Toyota.domain.com/viewall.php [R=301,L]
    
    RewriteCond %{HTTP_HOST} ^www\.domain\.com
    RewriteCond %{REQUEST_URI} ^/viewall.php?cat=5$ [NC]
    RewriteRule ^(.*)  http://Honda.domain.com/viewall.php [R=301,L]
    
    RewriteCond %{HTTP_HOST} ^www\.domain\.com
    RewriteCond %{REQUEST_URI} ^/viewall.php?cat=6$ [NC]
    RewriteRule ^(.*)  http://Acura.domain.com/viewall.php [R=301,L]
    
    RewriteCond %{HTTP_HOST} ^www\.domain\.com
    RewriteCond %{REQUEST_URI} ^/viewall.php?cat=7$ [NC]
    RewriteRule ^(.*)  http://Nissan.domain.com/viewall.php [R=301,L]
    
    RewriteCond %{HTTP_HOST} ^www\.domain\.com
    RewriteCond %{REQUEST_URI} ^/viewall.php?cat=8$ [NC]
    RewriteRule ^(.*)  http://Chevy.domain.com/viewall.php [R=301,L]
    Code (markup):
    R=301 issues a 301 (moved permanently) response. If you don't want to 301 redirect those pages then replace all [R=301,L] with [L]
     
    AHA7, Nov 9, 2007 IP
    sundaybrew likes this.
  11. tru504187211

    tru504187211 Peon

    Messages:
    287
    Likes Received:
    15
    Best Answers:
    0
    Trophy Points:
    0
    #11
    Lovely....I will implement and test them tonight. If they work, expect money in your paypall account. PM over your paypal email address.

    Thanks for the help!!!
     
    tru504187211, Nov 9, 2007 IP