Need Help with redirections

Discussion in 'Programming' started by WebEvader, Aug 13, 2011.

  1. #1
    Hi,

    Is it possible for me to redirect http:// webeavder.org/forums to http:// forums.webevader.org ? Or will that create problems.

    Any advice will be most helpful ;)
     
    WebEvader, Aug 13, 2011 IP
  2. ssmm987

    ssmm987 Member

    Messages:
    180
    Likes Received:
    4
    Best Answers:
    3
    Trophy Points:
    43
    #2
    What do you want, that forums.site.org shows site.org/forums, or that it really redirects?

    Anyway, in both cases you need to create a .htaccess file, and put it in the main directory.

    In the first case, add this in your htaccess file:
    
    # get requested hostname
    RewriteCond %{HTTP_HOST} (.*\.|)(.*\..*|.*\..*\..*)$ [NC]
    RewriteRule ^forums.(.*)/(.*) /forums/$2 [L]
    
    Code (markup):
    In the second case, add this

    
    # get requested hostname
    RewriteCond %{HTTP_HOST} (.*\.|)(.*\..*|.*\..*\..*)$ [NC]
    # convert /forum/viewtopic.php to forum.hostname/viewtopic.php
    RewriteRule ^(.*)forums/(.*|)$ http://forums.%2/$1 [R=301,L]
    
    Code (markup):
    (Not tested though)
     
    ssmm987, Aug 13, 2011 IP
    cgoly01 likes this.