Why Won't This Redirect Method Work?

by 10 replies
11
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?
#website design #method #redirect #work
  • Hi,

    .htaccess

    Redirect 301 fruit.com/apples.html fruit.info
    • [1] reply
    • 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.
  • You should add not replace, did you make a copy?
    • [1] reply
    • 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.
  • add to the .htaccess for the relevant directory, I could not add http and www to my post but you should add them
    • [1] reply
    • Do I add the http and www on both the fruit.com/apples and the fruit.info?
  • Hi,

    yes add to both

    I have a link that explains it well but I cant add links yet
  • 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)
  • 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.
  • Unless you've got your server set up to run .html files through the PHP interpreter, it should be expected to do nothing.

Next Topics on Trending Feed