Benches Uncategorized

5

301 Redirects: All works except...(help, coding...

apple Verified

Imported from the Apple Support Forums via the Wayback Machine 🔗

Hi,

Thanks to everyone who's helped with 301 redirects to date.

I figured I'd start a new thread to ask about one of the finer points of 301 redirects in iWeb.

To summarize:

To add a 301 redirect in iWeb, you add an .htaccess file to the root of your directory with the following code:

redirect 301 /page1.html http://www.mydomain.com/page2.html

or

redirect 301 /page1 http://www.mydomain.com/page2.html

That works!

EXCEPT...

the page it lands on is:

http://www.mydomain.com/page2.html/

Note the backslash at the end of the URL in the arrival page.

That @#$# backslash makes the iWeb page not present properly.

You remove the backslash, it works.

You keep it in (e.g., everyone in the world who clicks on your original link and doesn't know to alter the URL of the messed up arrival page), and you get a page of gobbledygook - no pictures, dot for navbar, overlapping textmess.

So....

Does anyone know how to write the line in the 301 redirect so the arrival page ends in an iWeb friendly:

http://www.mydomain.com/page2.html

NOT

http://www.mydomain.com/page2.html/

???

Thanks in advance if you have the answer to this chestnut.

-Matt

5 replies

Sign in or join Beachball Help to reply.

  1. 0

    Apple Support Community member

    Imported from the Apple Support Forums via the Wayback Machine 🔗

    Matt:

    I don't know what the benefits of a 301 redirect but Cyclosaurus provided this javascript HTML snippet for redirecting from one page to another:

    <script type="text/javascript">
    parent.window.location = "URL to new page"; </script>

    Put that snippet in the page and it will immediately redirect to the new url. I don't know if it's what you want but it's another way to redirect.

    I'm guessing that the snippet method isn't search engine friendly, right?

    OT

    Message was edited by: Old Toad

  2. 0

    Apple Support Community member

    Imported from the Apple Support Forums via the Wayback Machine 🔗

    Old Toad wrote:
    I don't know what the benefits of a 301 redirect but Cyclosaurus provided this javascript HTML snippet for redirecting from one page to another:

    Put that snippet in the page and it will immediately redirect to the new url. I don't know if it's what you want but it's another way to redirect.

    I'm guessing that the snippet method isn't search engine friendly, right?

    Thanks for the reply.

    Yeah- the problem is the original page no longer exists. So any attempt to click on a link to it will frustrate a web surfer, and the link looses its search value as well. A 301 redirect preserves the value of the link both for the user and for the search engine.

    The problem with the snippet - as I understand it - is that the original page no longer exists and can't be recreated in iWeb. However, a 301 will redirect from the original address to an iWeb alternative.

  3. 0

    Apple Support Community member

    Imported from the Apple Support Forums via the Wayback Machine 🔗

    You could create a dummy page with a text editor, name it with the same name as the old page's html file and put in the following text:

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/1999/REC-html401-19991224/loose.dtd">
    <html>
    <head><meta http-equiv="REFRESH" content="0;url=URL TO NEW PAGE"> </head>

    <body>

    </body>
    </html>

    The content= "0" is the delay time for redirect. You could put in a 5 to 8 second delay with a message between the body tags about the new site and a reminder to bookmark the new site.

    Or create a new site with one page and the message as you want it and publish to a folder. Then take the one page out, rename it as you want, add the <meta http-equiv="REFRESH" content="0;url=URL TO NEW PAGE"> before the </head> tag save and upload to the server. Then it will look like you want it for the few seconds it will take to redirect.

    Lots of way to skin this cat.

  4. 0

    Apple Support Community member

    Imported from the Apple Support Forums via the Wayback Machine 🔗

    Thanks, Old Toad.

    I'll play around with this.

    As I'm not all that web-coding savvy, I wonder if this will preserve the link value the way it would with a 301?

    I just wish there were a way to make a straight up 301 in iWeb that worked. I may be doing something wrong so if anyone has been able to implement a 301 with success, or has been able to get the target page to land without the final "/", please pipe in.

    Nonetheless, many thanks.

    I've learned with iWeb, you have to be prepared to skin the cat with plan b and plan c cat skinning methods when the primary method leaves the cat not entirely skinned, or with skin that's not quite formatted correctly or the cat would like its skin back but the search engine is having a hard time finding it without a sitemap.

  5. 0

    Apple Support Community member

    Imported from the Apple Support Forums via the Wayback Machine 🔗

    MattiMattMatt wrote:
    Hi,

    To summarize:

    To add a 301 redirect in iWeb, you add an .htaccess file to the root of your directory with the following code:

    redirect 301 /page1.html http://www.mydomain.com/page2.html

    or

    redirect 301 /page1 http://www.mydomain.com/page2.html

    That works!

    EXCEPT...

    the page it lands on is:

    http://www.mydomain.com/page2.html/

    Note the backslash at the end of the URL in the arrival page.

    That @#$# backslash makes the iWeb page not present properly.

    So....

    Does anyone know how to write the line in the 301 redirect so the arrival page ends in an iWeb friendly:

    http://www.mydomain.com/page2.html

    NOT

    http://www.mydomain.com/page2.html/

    ???

    I believe I've figured out the answer. So for the sake of anyone who might have the same question and stumble on this thread, I figured I'd write it in.

    The original external site that's linking (trying to link to mine) is using a backslash in its link:

    "http://www.mydomain.com/page1/"

    Using the standard 301:

    "redirect 301 /page1 http://www.mydomain.com/page2.html"

    ... results in an unreadable:

    "http://www.mydomain.com/page2.html/"

    The solution is to add the backslash to the original term in the 301 (after "page 1") so it matches the link in the external website:

    "redirect 301 /page1/ http://www.mydomain.com/page2.html"

    That works!