Rewrite needed - odd situation

Discussion in 'Apache' started by NickR25, May 10, 2009.

  1. #1
    This is what I think will be difficult to pull off (at least for me) so I'm looking for some help.

    Here's the scoop: I have a WordPress blog in my site's root but a forum in the /forums directory.
    I am wanting to move the blog to a /blog directory and have nothing in the root.
    Essentially, I need to redirect users who are trying to access a blog post (which would be in the format of mysite.net/category/post-id_postname) to the same URL but in the blog directory (e.g. mysite.net/blog/category/post-id_postname).
    However, I want users who are trying to access a forum URL (anything with /forums in it such as mysite.net/forums/showthread.php?t=12345) to be left alone and un-affected by this change.

    Does this make sense?

    Any help with writing the rewrite rule for my .htaccess is greatly appreciated. Thanks.
     
    NickR25, May 10, 2009 IP
  2. vx|brian

    vx|brian Peon

    Messages:
    34
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Most of the Rewrite rules if correctly coded will not do that, because they would only be assigned to /category, etc, if they are assigned to everything (redirect everything), its an example of poor coding!
     
    vx|brian, May 10, 2009 IP
  3. Lpe04

    Lpe04 Peon

    Messages:
    579
    Likes Received:
    15
    Best Answers:
    0
    Trophy Points:
    0
    #3
    you could try this, there may be a better way of doing this, but

    
    RewriteCond %{REQUEST_URI} !(forums | blog)
    Rewriterule (.*) http://www.mydomain.com/blog/$1 [L,R=301]
    
    Code (markup):
     
    Lpe04, May 14, 2009 IP