Changing rewrite rules and redirecting to new ones

Discussion in 'Programming' started by vexx, Aug 6, 2012.

  1. #1
    I have a small problem. I want to change my rewrite rules for a folder to a subdomain and then redirect old rules to new ones

    So basically I have this:

    RewriteRule ^news/index([0-9-]+)\.html$ index.php?page=pressrelease_homepage&pn=$1
    RewriteRule ^news/$ index.php?page=pressrelease_homepage
    RewriteRule ^press/([a-zA-Z0-9-]+)-([0-9-]+)\.html$ index.php?page=pressrelease_page&id=$2
    Code (markup):
    I want to rewrite everything /news to press.domain.com and everything /press/ to press.domain.com. After I do this, I want to redirect all old links to the new subdomain links. I tried several methods but I wasn't very successful.

    Any ideeas?
     
    vexx, Aug 6, 2012 IP
  2. vexx

    vexx Well-Known Member

    Messages:
    204
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    123
    #2
    anyone has any idea?
     
    vexx, Aug 6, 2012 IP
  3. nhl4000

    nhl4000 Well-Known Member

    Messages:
    479
    Likes Received:
    14
    Best Answers:
    0
    Trophy Points:
    110
    #3
    everything /news to press.domain.com:

    
    RewriteRule ^news/$ http://press.domain.com/
    
    Code (markup):
    www.domain.com/news/ will redirect to http://press.domain.com

    everything /press/ to press.domain.com:

    
    RewriteRule ^press/$ http://press.domain.com/
    
    Code (markup):
    www.domain.com/press/ will redirect to http://press.domain.com/

    redirect all /news/xxx and /press/xxx to press.domain.com/xxx

    
    RewriteRule ^news/([A-Z­a-z­0-9­-]+)/?$ http://press.domain.com/$1 [L]
    RewriteRule ^press/([A-Z­a-z­0-9­-]+)/?$ http://press.domain.com/$1 [L]
    
    Code (markup):
    I HAVENT tested. This was based on memory + referencing the mod_rewrite Cheat Sheet. If you haven't, download a copy: http://www.cheatography.com/davechild/cheat-sheets/mod-rewrite/
     
    nhl4000, Aug 7, 2012 IP
  4. vexx

    vexx Well-Known Member

    Messages:
    204
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    123
    #4
    sorry for the late response...was off for the weekend.

    I tried your rules, but none of them would do anything. I also looked on the cheat sheet..but I couldn't get any help from it. I'm also a beginner and...this is all relatively new for me, that's why I need some help. Tnx again
     
    vexx, Aug 13, 2012 IP
  5. deathshadow

    deathshadow Acclaimed Member

    Messages:
    9,732
    Likes Received:
    1,999
    Best Answers:
    253
    Trophy Points:
    515
    #5
    Is that your full .htaccess rules? Are you setting "RewriteEngine On" before those?
     
    deathshadow, Aug 13, 2012 IP
  6. vexx

    vexx Well-Known Member

    Messages:
    204
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    123
    #6
    here's the .htacess rules

    RewriteEngine On
    RewriteBase /
    RewriteRule ^news/index([0-9-]+)\.html$ index.php?page=pressrelease_homepage&pn=$1
    RewriteRule ^news/$ index.php?page=pressrelease_homepage
    RewriteRule ^press/([a-zA-Z0-9-]+)-([0-9-]+)\.html$ index.php?page=pressrelease_page&id=$2
    Code (markup):
     
    vexx, Aug 23, 2012 IP