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

htaccess page

Discussion in 'Black Hat SEO' started by DisavowedKing, Mar 22, 2011.

  1. DisavowedKing

    DisavowedKing Regular Member

    Joined:
    Sep 1, 2010
    Messages:
    243
    Likes Received:
    84
    Gender:
    Male
    Occupation:
    Marketing - Email, Direct Mail, and Internet
    Location:
    San Diego, CA
    I am trying to redirect one page to another with htaccess:

    mywebsite.c0m/folder/index.h t m l

    301 redirect to:

    mywebsite.c0m/folder/

    What is the code to do this? I have several pages I need to do this for and it will be EXTREMELY helpful.

    Also I tried google and everytime I looked at a new website they had different code for the htaccess page. Thanks for the help.

    I did a search (in BHW) and I couldn't find anything about this plus I wasn't sure if this was the best section but figured it had to do with website design more than anything so if it is in the wrong section sorry.
     
  2. cjbmeb14

    cjbmeb14 Regular Member

    Joined:
    Jul 17, 2008
    Messages:
    228
    Likes Received:
    276
    Occupation:
    Self Employed
    Location:
    Worcester,UK
    copy the following into a notepad file and save as index.php:
    <?php
    header("HTTP/1.1 301 Moved Permanently");
    header("Location: http://www.yournewdomain.com/page.html");
    exit();
    ?>
    Now upload this to the main directory in your domain.
     
  3. DisavowedKing

    DisavowedKing Regular Member

    Joined:
    Sep 1, 2010
    Messages:
    243
    Likes Received:
    84
    Gender:
    Male
    Occupation:
    Marketing - Email, Direct Mail, and Internet
    Location:
    San Diego, CA
    Thanks cjbmeb14 but I have content already on the index.php file. That's why I want to use the htaccess page to do the 301 redirect. Like doing the non-www to w w w.

    Any thoughts?
     
  4. DisavowedKing

    DisavowedKing Regular Member

    Joined:
    Sep 1, 2010
    Messages:
    243
    Likes Received:
    84
    Gender:
    Male
    Occupation:
    Marketing - Email, Direct Mail, and Internet
    Location:
    San Diego, CA
    Does google see these as two different sites? If you follow along with their thoughts on non-www and w w w then it would make sense that they would think the same about website/folder and website/folder/index.h t m l

    Is anyone doing this in their htaccess page? If so what is the code?
     
  5. gimme4free

    gimme4free Executive VIP Jr. VIP Premium Member

    Joined:
    Oct 22, 2008
    Messages:
    1,879
    Likes Received:
    1,932
  6. DisavowedKing

    DisavowedKing Regular Member

    Joined:
    Sep 1, 2010
    Messages:
    243
    Likes Received:
    84
    Gender:
    Male
    Occupation:
    Marketing - Email, Direct Mail, and Internet
    Location:
    San Diego, CA
    What about for deeper folders?

    website/folder/folder/index.h t m l

    redirect to:

    website/folder/folder
     
  7. gimme4free

    gimme4free Executive VIP Jr. VIP Premium Member

    Joined:
    Oct 22, 2008
    Messages:
    1,879
    Likes Received:
    1,932
    RewriteRule ^([^/]*)/index.html $1/index.php [R=301]

    You can instead use htaccess to set the index file of a folder using:
    DirectoryIndex index.php
     
  8. DisavowedKing

    DisavowedKing Regular Member

    Joined:
    Sep 1, 2010
    Messages:
    243
    Likes Received:
    84
    Gender:
    Male
    Occupation:
    Marketing - Email, Direct Mail, and Internet
    Location:
    San Diego, CA
    So if you are already using index.php then you don't need the rewrite rule and instead just use the directoryindex?