1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

XF 1.2 Forum in index but moving to "community"

Discussion in 'XenForo Questions and Support' started by Neal, Jul 9, 2013.

  1. Neal

    Neal Well-Known Member

    I've moved my forum from my site root to a folder called "community". I want to redirect everything at mydomain.com to the new forum/thread locations with a 301.

    I've tried doing it via cpanel but I get a message stating it can't be done due to redirect looping.

    I currently have an index.php file in the root forwading to the "community" folder (But this doesn't redirect the old threads/urls/etc...). I've also edited the default XenForo .htaccess to remove the www. from the domain so http://www.mysite.com/community/ becomes http://mysite.com/community/.

    Help appreciated please :)
     
  2. Tracy Perry

    Tracy Perry Well-Known Member

    Are you totally removing the forum from the root and over to /community? What does the index.php in root consist of (is it the forum index.php - in which case is not going to work)?
    Most times you move your forum over, modify your web servers to use the new directory as the base <the root location> (unless you are putting a Wiki or something in the root and then making a link to the forum from it or bridging it) and that's pretty much it. If you are doing the latter then your index.php should not have any redirects in it - but your .htaccess may need rewrites.
     
  3. Neal

    Neal Well-Known Member

    My index.php at the moment:

    I'm not having anything in the root at this time but may add a basic page or a CMS at some point. I just like it being more organised and having the forum in its own folder/area.
     
  4. Tracy Perry

    Tracy Perry Well-Known Member

    Probably the easiest thing to do right now would be simply make the /community your root for your web server - and once you install the CMS then you can change it back to being wherever it is now.
    The .htaccess in the root is probably going to need to be edited to control the rewrites to the correct location for you now instead of using a PHP file. That's probably what is causing your loops.
     
  5. Neal

    Neal Well-Known Member

    I tried doing it via .htaccess but it gave me a loop error so I changed to the index.php file but really I need everything going to my root going to /community/
     
  6. Tracy Perry

    Tracy Perry Well-Known Member

    Did you try something like this in your .htaccess?
    Code:
    RedirectMatch 301 ^/(.*)$ http://www.site.com/community/$1
    And be sure that the .htaccess is not defined in your /community also.
     
  7. Neal

    Neal Well-Known Member

    So put that into a new .htaccess in the root of the site and leave the one in /community/ alone?
     
  8. Tracy Perry

    Tracy Perry Well-Known Member

    Put it in the root one and rename the one in /community as .htaccess.old. You may be able to just move the one from the /community into the root and see if that works (with that rewrite rule near the top). I use nginx so I'm not real familiar with apache's rewrite rules like I am nginx. @Jake Bunce is one of the rewrite rule gurus.
     
  9. Tracy Perry

    Tracy Perry Well-Known Member

    You may only need to change the ReWrite Base to reflect /community instead of the default /.
     
  10. Neal

    Neal Well-Known Member

    I've got this now in a .htaccess in the root of my domain:

    Only issue is that if someone goes to "talkgeek.net/threads/a-thread-name-5424" it doesn't redirect to "talkgeek.net/community/threads/a-thread-name-5424"
     
  11. Neal

    Neal Well-Known Member

    I appreciate the help but I'm getting confused and still having some issues. I'll open up a ticket and see if XenForo staff can help :)
     
  12. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    Put this in your .htaccess file in the web root:

    Code:
    RewriteEngine On
    
    RewriteRule ^(threads|forums|members)/(.*)$ /community/$1/$2 [R=301,L]
    
    You need to specify each XenForo route that you want to redirect to the new location. I included the important routes above. The rest don't matter as much.
     
    Neal and Tracy Perry like this.
  13. Tracy Perry

    Tracy Perry Well-Known Member

    Yay!!!!! Jake to save the day!!!
    Jake, does he still need his default .htaccess in the root of his old directory or a new one and keep the old one in the /community? Or should he delete the /community one?
     
  14. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    ^this^
     
    Tracy Perry likes this.
  15. Tracy Perry

    Tracy Perry Well-Known Member

    I like nginx so much better. For my convoluted mind I can figure it out easier. :confused:
     
    Neal likes this.
  16. Neal

    Neal Well-Known Member

  17. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    Adding to the above rule...

    Code:
    RewriteEngine On
    
    RewriteRule ^(threads|forums|members)/(.*)$ /community/$1/$2 [R=301,L]
    RewriteRule ^$ /community/ [R=301,L]
    
     
    Tracy Perry and Neal like this.
  18. Neal

    Neal Well-Known Member

    You are a star thank you very much! (y)
     
  19. Tracy Perry

    Tracy Perry Well-Known Member

    Told you @Jake Bunce was the rewrite guru!
     
    Neal likes this.

Share This Page