Results 1 to 6 of 6
  1. #1
    Join Date
    Apr 2001
    Posts
    239

    domain redirect problem

    I've changed the domain name of my phpbb forum from forum.old-domain.com to forum.new-domain.com. Any tips how would I automatically redirect same data from old URLs to new ones?

    Example is to automatically redirect http://forum.old-domain.com/viewtopic.php?p=12345 to http://forum.new-domain.com/viewtopic.php?p=12345.

    I got a hint mod rewrite can do this but when I checked its manual, I found out it is a voodoo. Any help from voodoo experts here is appreciated.

  2. #2
    post here http://forum.modrewrite.com/


    they are normally very helpful with mod rewrite issues

  3. #3
    Join Date
    Apr 2001
    Posts
    239
    Thanks saghir. I got it working. Had to learn some voodoo myself.

  4. #4
    Join Date
    Mar 2004
    Posts
    1,301
    it would be nice if you could post up what you have just learned someone might need it

  5. #5
    Join Date
    Apr 2001
    Posts
    239
    Here it is:

    To solve the problem I've initially posed above, write the ff code to the .htaccess file located at the root directory of your old forum (http://forum.old-domain.com/):


    RewriteEngine ON
    RewriteRule ^(.*)$ http://forum.new-domain.com/$1 [R=301,L]


    -----
    Explanation of the above incantation (RewriteRule):

    ^(.*)$ -- the kind of files you want redirected, in this case, all files (from the root of you domain) as indicated by the dot and asterisk enclosed in parenthesis. The caret (^) and dollar symbols signify the beginning and end of your rule. Additionally, the file that is being accessed is automatically saved into a variable.

    http://forum.new-domain.com/$1 -- the URL that it is being redirected into. The $1 is the first variable that was saved by the program which was the first occurence of a parenthesized regular expression (in this instance the "(.*)".

    [R=301,L] -- Flags used to tell apache that it is a permanent redirection (R=301). L tells apache that it is the last rule.

  6. #6
    hello

    i put such a redirect

    RewriteEngine On
    RewriteCond %{HTTP_HOST} !^www\.domain\.net
    RewriteRule (.*) http://www.domain.net/$1 [R=301,L]

    and it works fine.
    now i need to redirect domain.net/old [it's the old homepage] to domain.net.

    i'm trying to use such code, but this don't work

    RewriteEngine On
    RewriteCond %{HTTP_HOST} !^www\.domain\.net
    RewriteCond %{HTTP_HOST} !^www\.domain\.net/old
    RewriteRule (.*) http://www.domain.net/$1 [R=301,L]

    can u tell, what i do wrong?
    Your Health Encyclopedia
    Medical and health consumer information resources containing comprehensive and unbiased information in patient-friendly language

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •