Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Try Vanilla Forums Cloud product

Ready to contribute?

Amazing! Sign our contributors' agreement and then join us on GitHub.

Vanilla 2.3 fully supports PHP 7. Get it now!
Please upgrade to 2.3 here. The 2.2 and earlier branches are no longer being updated.

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

shozen1shozen1 New
edited March 2012 in Vanilla 2.1 & Earlier Help

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 :)

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.

    shozen1

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

  • @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?

  • 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

  • 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!

  • 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.

  • 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...

  • 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.

    shozen1
  • 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!

  • neyawnneyawn New
    edited July 2012

    Can you share what worked for you?

    UnderDog
Sign In or Register to comment.