.htacces Redirection problem

Discussion in 'Apache' started by nivosh, Mar 28, 2009.

  1. #1
    Hello.

    i am trying to find a solution to this problem for some days now.

    I have installed my wordpress blog in somedomain.com/blog
    for several months it was live with visitors and all that.
    a week ago i decided to direct all my visitors to the root so i configured wordpress to show all the posts in / instead of /blog and all my parmalink structure has changed accordingly. for example: mydomain.com/blog/somecategory/somepost is now:mydomain.com/somecategory/somepost

    but since i didn't want to lose all my outbound links that was published before the change and deal with alot of 404's i did a .htaccess redirect as follows:
    Redirect 301 /blog/ http://my domain.com/

    so every link out there thats included the /blog prefix was now redirected to the /root.

    but now for the problem: since every address contains /blog is redirected to root, i cant login to my admin panel because it is located in the /blog folder.
    and every management directive in wordpress is in /blog folder.


    Please help me with that guys...
     
    nivosh, Mar 28, 2009 IP
  2. Lpe04

    Lpe04 Peon

    Messages:
    579
    Likes Received:
    15
    Best Answers:
    0
    Trophy Points:
    0
    #2
    RewriteCond %{REQUEST_URI} !(wp-admin|wp-content|wp-includes)
    RewriteRule ^blog/ http://mydomain.com/? [R=301,L]
    Code (markup):
    Please rep if I was helpful ;) Thanks.
     
    Lpe04, Mar 29, 2009 IP
  3. nivosh

    nivosh Peon

    Messages:
    8
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Thanks for the help.
    unfortunately the code you provided did not remove the /blog prefix from the url.

    this is the code i used:

    RewriteEngine On
    RewriteBase /
    RewriteCond %{REQUEST_URI} !(wp-admin|wp-content|wp-includes)
    RewriteRule ^blog/ http://emetaheret.org.il/? [R=301,L]
    Code (markup):
    i'm sure it's a misspelled error or something...
     
    nivosh, Mar 30, 2009 IP
  4. Lpe04

    Lpe04 Peon

    Messages:
    579
    Likes Received:
    15
    Best Answers:
    0
    Trophy Points:
    0
    #4
    RewriteEngine On
    RewriteBase /
    RewriteCond %{REQUEST_URI} !(wp-admin|wp-content|wp-includes)
    RewriteRule ^blog/(.*) http://mydomain.com/$1? [R=301,L]
    Code (markup):
     
    Lpe04, Mar 31, 2009 IP
  5. nivosh

    nivosh Peon

    Messages:
    8
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    still not working...

    When i use the url:
    http://emetaheret.org.il/blog
    Code (markup):
    The Htaccess code does not redirect me to:
    http://emetaheret.org.il
    Code (markup):
    this is the full .htaccess file for you to see.
    maybe something there is not right:

    # Permanent redirection
    # RedirectMatch 301 ^/blog/$ http://emetaheret.org.il/
    # Redirect 301 /blog/ http://emetaheret.org.il/
    RewriteEngine On
    RewriteBase /
    RewriteCond %{REQUEST_URI} !(wp-admin|wp-content|wp-includes)
    RewriteRule ^blog/(.*) http://emetaheret.org.il/$1? [R=301,L]
    
    # BEGIN WordPress
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
    </IfModule>
    
    # END WordPress
    Code (markup):
    for now, i restored the redirection command:
    RedirectMatch 301 ^/blog/$ http://emetaheret.org.il/
    Code (markup):
    in order not to lose visitors.
     
    nivosh, Apr 1, 2009 IP
  6. Lpe04

    Lpe04 Peon

    Messages:
    579
    Likes Received:
    15
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Try adding a forward slash before blog/

    RewriteRule ^/blog/(.*) http://emetaheret.org.il/$1? [R=301,L]
    Code (markup):
    Cheers
     
    Lpe04, Apr 1, 2009 IP
  7. nivosh

    nivosh Peon

    Messages:
    8
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #7
    Still Doesn't work...

    The url: http://emetaheret.org.il/blog
    Code (markup):
    returns:

    http://emetaheret.org.il/blog/
    Code (markup):
     
    nivosh, Apr 2, 2009 IP
  8. FreedomFighter1210

    FreedomFighter1210 Banned

    Messages:
    307
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    0
    #8
    Sorry for the mess - but I can't post links apparently...

    Redirect 301 / httpyourwebsitehere

    You can also try making an index.php file in that directory, and putting this in it:
    <?php
    header( 'Location: httpyourwebsitehere' ) ;
    ?>

    Those should take you directly to whatever address you put in.
     
    FreedomFighter1210, Apr 2, 2009 IP
  9. nivosh

    nivosh Peon

    Messages:
    8
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #9
    Hi.

    you can post links when you rap them in "code" tag...

    I allready tried the :
     Redirect 301 /blog/ http://my domain.com/
    Code (markup):
    method but the problem was that it also redirected my admin address which has to be with the /blog prefix.

    Read my first Quastion...
     
    nivosh, Apr 2, 2009 IP
  10. FreedomFighter1210

    FreedomFighter1210 Banned

    Messages:
    307
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    0
    #10
    Well then what about the index.php redirection method?
     
    FreedomFighter1210, Apr 2, 2009 IP
  11. infomalaya

    infomalaya Banned

    Messages:
    103
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #11
    infomalaya, Apr 3, 2009 IP
  12. nivosh

    nivosh Peon

    Messages:
    8
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #12
    I think that it's not a good idea from the seo point of view...
     
    nivosh, Apr 4, 2009 IP
  13. FreedomFighter1210

    FreedomFighter1210 Banned

    Messages:
    307
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    0
    #13
    And what are you basing that off of, Nivosh?

    A redirect doesn't affect your SEO - the engine just updates accordingly.
     
    FreedomFighter1210, Apr 4, 2009 IP