I need to rewrite <mydomain>.com/forums to forums.<mydomain>.com

Discussion in 'PHP' started by TasteOfPower, Mar 21, 2007.

  1. #1
    can someone do this for me? Iwould think its a simple thing...

    help! thx.
     
    TasteOfPower, Mar 21, 2007 IP
  2. Foxy

    Foxy Chief Natural Foodie

    Messages:
    1,614
    Likes Received:
    48
    Best Answers:
    0
    Trophy Points:
    0
    #2
    When you establish the sub domain it makes a folder/directory called forums. So before you do that you need to rename your forums directory as forums1 [for example] then make the sub domain - return to the public_html rename the new forums as forums2 [or delete it] and then rename forums1 as forums.

    Hey presto it is done. When the sub-domain is finally propagated it automatically leads to the directory.
     
    Foxy, Mar 21, 2007 IP
  3. TasteOfPower

    TasteOfPower Peon

    Messages:
    572
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    0
    #3
    hmm....i mean like....when a user types in <domain>.com/forums/showthread.php?t=32323 it will take them to forums.<domain>.com/showthread.php?t=32323

    ya know? ? or is that how i do it?(like u said?)
     
    TasteOfPower, Mar 21, 2007 IP
  4. itrana123

    itrana123 Peon

    Messages:
    177
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #4
    very hard to understand wat you want us to do for you. i think you want a URL rewriting sort of things am i right?
     
    itrana123, Mar 21, 2007 IP
  5. TasteOfPower

    TasteOfPower Peon

    Messages:
    572
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    0
    #5
    yes you are right. i want my forum url like DP's instead of like www.dp.com/forums, i want forums.dp.com got me? but i have a lot of links in google like www.dp.com/forums/showthread.php?t=34242 and stuff like that......so i need to get thse incoming requests set to the new url.

    make sense?
     
    TasteOfPower, Mar 21, 2007 IP
  6. probidtemplates.com

    probidtemplates.com Banned

    Messages:
    3
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    All you have to do is create a subdomain for your site, in this case your subdomain should be "forums". Then after it is active, go to your admin control panel for the forum and change your settings
    from:
    http://www.domain.com/forums/
    to:
    http://forums.domain.com/

    That's it! :)
     
    probidtemplates.com, Mar 21, 2007 IP
  7. rodney88

    rodney88 Guest

    Messages:
    480
    Likes Received:
    37
    Best Answers:
    0
    Trophy Points:
    0
    #7
    Assuming Apache with mod_rewrite enabled - put in a domain.com/.htaccess file:
    Options +Indexes
    Options +FollowSymlinks
    RewriteEngine on
    RewriteBase /
    RewriteRule ^forums/(.*)$ http://forums.domain.com/$1 [R=301,L]
    Code (markup):
    That should 301 redirect all SE and users to the new location of your forums.
     
    rodney88, Mar 21, 2007 IP
  8. TasteOfPower

    TasteOfPower Peon

    Messages:
    572
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    0
    #8
    yes i know that part. now when someone types domain.com/forums/showthread.php?t=32332, they need to be redirected to forums.domain.com/showthread.php?t=32332

    anyway.....rodney answered the question. but now im thinking...what i need is just a redirect......not a rewrite?

    just something that changes www.domain.com/forums part of the domain to forums.domain.com.

    what do you all think???
     
    TasteOfPower, Mar 21, 2007 IP
  9. rodney88

    rodney88 Guest

    Messages:
    480
    Likes Received:
    37
    Best Answers:
    0
    Trophy Points:
    0
    #9
    Yes, you need to redirect - if you rewrite, the old URLs will continue to work and display the same content as the new URLs (forums.domain.com), and you may be penalised for duplicate content. A 301 redirect will tell SE your pages have moved and they will carry across your rankings, etc. to the new locations.

    mod_rewrite allows you to do both rewriting and redirecting. I included the R=301 flag for the RewriteRule to tell it to do a 301 permanent redirect.
     
    rodney88, Mar 21, 2007 IP
  10. TasteOfPower

    TasteOfPower Peon

    Messages:
    572
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    0
    #10
    So about the redirect......all I do is....what exactly? I know you said you put it in your other reply.....but uh....

    RewriteBase /
    RewriteRule ^forums/(.*)$ http://forums.domain.com/$1 [R=301,L]

    ?? ?
     
    TasteOfPower, Mar 21, 2007 IP
  11. rodney88

    rodney88 Guest

    Messages:
    480
    Likes Received:
    37
    Best Answers:
    0
    Trophy Points:
    0
    #11
    Create a .htaccess in the root of your domain containing:
    Options +Indexes
    Options +FollowSymlinks
    RewriteEngine on
    RewriteBase /
    RewriteRule ^forums/(.*)$ http://forums.domain.com/$1 [R=301,L]
    Code (markup):
    (1) and (2) The first two lines are just Apache options which are needed for the rewrite module. It's likely these will already be set in the httpd.conf so in most cases you can leave them out, but it doesn't hurt to keep them.
    (3) Then we tell it we want to do some rewriting so we turn on the rewrite engine. Fairly self-explanatory.
    (4) We specifiy the root level of our domain as the base to rewrite from.
    (5) The RewriteRule has the syntax of RewriteRule PATTERN DESTINATION. We're using a regex pattern that starts with "forums/", then matches everything that follows. The brackets around the .* mean we capture the match into a backreference to use in the destination. Then we at the end we append the R=301 flag to tell the server to send a 301 permanently moved header and redirect the user. And the L flag for Last so that we stop rewriting here.

    Simply save the file as .htaccess (or anything else and rename once uploaded), and upload it to domain.com/.htaccess
     
    rodney88, Mar 22, 2007 IP
  12. TasteOfPower

    TasteOfPower Peon

    Messages:
    572
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    0
    #12
    THX! For the info :D:D :D
     
    TasteOfPower, Mar 22, 2007 IP