Why Won't This Redirect Method Work?

10 replies
  • WEB DESIGN
  • |
This is separate from my other post.

Here I want to do a redirect from a subdirectory .HTML page on one domain to the top level of another domain.

So basically I want to go from:

ww#w.fruit.com/apples.html

to:

ww#w.apples.info

I opened the .html apples page in Dreamweaver, deleted everything, and replaced it all with:

<?
Header( "HTTP/1.1 301 Moved Permanently" );
Header( "Location: http://www.apples.info" );
?>

Yet the redirect isn't working. What am I doing wrong here?
#method #redirect #work
  • Profile picture of the author Steveoo
    Hi,

    .htaccess

    Redirect 301 fruit.com/apples.html fruit.info
    {{ DiscussionBoard.errors[5643982].message }}
    • Profile picture of the author trentonlaura
      Originally Posted by Steveoo View Post

      Hi,

      .htaccess

      Redirect 301 fruit.com/apples.html fruit.info
      I pasted over everything else in the HTACCESS file with that line (making my site's changes of course), saved it, uploaded it to the fruit directory on my hosting... now I'm getting a 500 internal service error for the apples.html page.
      {{ DiscussionBoard.errors[5644081].message }}
  • Profile picture of the author Steveoo
    You should add not replace, did you make a copy?
    {{ DiscussionBoard.errors[5644344].message }}
    • Profile picture of the author trentonlaura
      Originally Posted by Steveoo View Post

      You should add not replace, did you make a copy?
      Yeah I reverted to the copy.

      Should this go in the HTAccess file for my root hosting account or for the HTAccess file of the Fruit directory specifically? All of my websites which run WordPress have HTAccess files in their specific directories on my hosting is why I ask.
      {{ DiscussionBoard.errors[5644493].message }}
  • Profile picture of the author Steveoo
    add to the .htaccess for the relevant directory, I could not add http and www to my post but you should add them
    {{ DiscussionBoard.errors[5644548].message }}
    • Profile picture of the author trentonlaura
      Originally Posted by Steveoo View Post

      add to the .htaccess for the relevant directory, I could not add http and www to my post but you should add them
      Do I add the http and www on both the fruit.com/apples and the fruit.info?
      {{ DiscussionBoard.errors[5644846].message }}
  • Profile picture of the author Steveoo
    Hi,

    yes add to both

    I have a link that explains it well but I cant add links yet
    {{ DiscussionBoard.errors[5644939].message }}
  • Profile picture of the author namaserajesh
    Try this code:


    RewriteEngine On
    RewriteCond %{HTTP_HOST} ^fruit.com/apples.html$ [NC]
    RewriteRule ^(.*)$ http://www.apples.info/$1 [R=301,L]
    RewriteCond %{HTTP_HOST} ^www.fruit.com/apples.html$ [NC]
    RewriteRule ^(.*)$ http://www.apples.info/$1 [R=301,L]

    Add this code in .htaccess at top level, it will redirect both www and without www version of old site to your new domain, also no effect on SEO. But I'm not sure is there any mistake in code as I'm also new in this .htacces coding (apache configuration)
    {{ DiscussionBoard.errors[5645359].message }}
  • Profile picture of the author trentonlaura
    Hmm I've tried both now without any change.

    I tried the shorter code from you Stevoo in my HTACCESS file for my apples.info directory on my hosting and I tried yours Namas in the HTACCESS for my top level, neither was working or produced any changes. I appreciate the help so far though.
    {{ DiscussionBoard.errors[5652350].message }}
  • Profile picture of the author mojojuju
    Unless you've got your server set up to run .html files through the PHP interpreter, it should be expected to do nothing.
    Signature

    :)

    {{ DiscussionBoard.errors[5652816].message }}

Trending Topics