Please upgrade here. These earlier versions are no longer being updated and have security issues.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.

moved forum to root from /forum/ how to 301 redirect?

shozen1shozen1 New
edited March 2012 in Vanilla 2.0 - 2.8

I have moved my forum to root from /forum/ and I understand this may be extremely obvious and im almost there but how to do this exactly? I need to redirect all pages to the new location in root...

Currently I am using redirect 301 /forum/ http://www.kaohsiungliving.org/ in .htaccess and it almost works but misses out the forward flash / before /discussion folder. Example.

http://www.kaohsiungliving.orgdiscussion/715/question-what-would-you-think-of-a-counselling-service-for-ex-pats/p1?p=discussion/715/question-what-would-you-think-of-a-counselling-service-for-ex-pats/p1

As you can see "www.kaohsiungliving.orgdiscussion/" no "/" before discussion This is probably an extremely easy thing to do, and I have googled away but have only found partial success.

Please help :)

There was an error rendering this rich post.

Tagged:

Best Answer

  • x00x00 MVP
    edited March 2012 Answer ✓

    I have a solution. Vanilla routes.

    First comment out the RedirectMatch in .htaccess

    then go to dashboard/routes -> Add Route

    Route Expression:

    forum(/.*)

    Target:

    $1

    Type:

    Permanent 301

    Done!

    Yes it is internal conflict of interest to answer your question.

    grep is your friend.

Answers

  • x00x00 MVP
    edited March 2012
    RedirectMatch ^/forum/.* http://www.kaohsiungliving.org/
    

    grep is your friend.

  • shozen1shozen1 New
    edited March 2012

    doesnt work - still no "/" before discussion folder. Redirects conversations without the "/" look closely at the redirected discussion url below:

    http://www.kaohsiungliving.orgdiscussion/715/question-what-would-you-think-of-a-counselling-service-for-ex-pats/p1?p=discussion/715/question-what-would-you-think-of-a-counselling-service-for-ex-pats/p1

    There was an error rendering this rich post.

  • @x00 thank you so much! its working like vanilla! one question though, what kind of redirect is this? I should be using 301, I think?

    There was an error rendering this rich post.

  • x00x00 MVP
    edited March 2012

    to redirect all uri

    RedirectMatch 301 ^/forum/(.*) http://www.kaohsiungliving.org/$1
    

    another way

     RewriteRule ^/forum/(.*) /$1 [R=301,L]
    

    grep is your friend.

  • shozen1shozen1 New
    edited March 2012

    Damn it! now its adding "/?p=forum/" before /discussion hence not redirecting properly. Example below.

    http://www.kaohsiungliving.org/?p=forum/discussion/710/native-american-english-teacher-looking-for-afternoon-evening-cram-school/p1

    There was an error rendering this rich post.

  • x00x00 MVP
    edited March 2012

    show the whole .htacess contents. Use <pre> tags. You have most like got thing in the wrong order.

    grep is your friend.

  • shozen1shozen1 New
    edited March 2012
    # Modified
    # If you modify this file then change the above line to: # Modified
    RedirectMatch ^/forum/.* http://www.kaohsiungliving.org/
    
       RewriteEngine On
       # Certain hosts may require the following line.
       # If vanilla is in a subfolder then you need to specify it after 
    
    the /. 
       # (ex. You put Vanilla in /forum so change the next line to: 
    RewriteBase /forum)
       # RewriteBase /
       RewriteCond %{REQUEST_FILENAME} !-d
       RewriteCond %{REQUEST_FILENAME} !-f
       RewriteRule ^(.*)$ index.php\?p=$1 [QSA,L]
    
    

    thank you for your time!

    There was an error rendering this rich post.

  • shozen1shozen1 New
    edited March 2012

    its missing parts of the .htaccess above, ill try pasting again:

    # Modified
    # If you modify this file then change the above line to: # Modified
    RedirectMatch ^/forum/.* http://www.kaohsiungliving.org/
    <IfModule mod_rewrite.c>
       RewriteEngine On
       # Certain hosts may require the following line.
       # If vanilla is in a subfolder then you need to specify it after the /. 
       # (ex. You put Vanilla in /forum so change the next line to: 
    RewriteBase /forum)
    
       # RewriteBase /
       RewriteCond %{REQUEST_FILENAME} !-d
       RewriteCond %{REQUEST_FILENAME} !-f
       RewriteRule ^(.*)$ index.php\?p=$1 [QSA,L]
    </IfModule>
    

    this ^ is exactly how my .htaccess looks.

    There was an error rendering this rich post.

  • shozen1shozen1 New
    edited March 2012

    using RedirectMatch 301 ^/forum/(.*) http://www.kaohsiungliving.org/$1 i get a double up of the discussion url - for example:

    http://www.kaohsiungliving.org/discussion/648/short-term-high-pay-public-teaching-position-in-china/p1?p=forum/discussion/648/short-term-high-pay-public-teaching-position-in-china/p1

    again - its almost there im so close...why has it duplicated the discussion part of the url?

    been trying to get this working for 3 hours now with only partial success...

    There was an error rendering this rich post.

  • x00x00 MVP
    edited March 2012 Answer ✓

    I have a solution. Vanilla routes.

    First comment out the RedirectMatch in .htaccess

    then go to dashboard/routes -> Add Route

    Route Expression:

    forum(/.*)

    Target:

    $1

    Type:

    Permanent 301

    Done!

    Yes it is internal conflict of interest to answer your question.

    grep is your friend.

  • shozen1shozen1 New
    edited March 2012

    YEEEEEEEEEEEEEEEEEEEEEEEEEES!!!! If i wasnt a raging HETROSEXUAL - I would give you a big kiss!!

    6 hours of PAIN come to an end!

    There was an error rendering this rich post.

  • neyawnneyawn New
    edited July 2012

    Can you share what worked for you?

Sign In or Register to comment.