Using the redirect function in Cpanel 9 ?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • erin
    Junior Member
    • May 2004
    • 5

    #1

    Using the redirect function in Cpanel 9 ?

    Hi,

    I am trying to use the permanant redirect function in cpanel 9. So far I have only been able to get it to redirect my main page i.e,(http://www.mainpage.com). How do I get to redirect the subpages in my website, i.e http://www.mainpage.com/whatever.htm ?

    I have entered in the file extensions and initiated the redirects, yet when I visit each address I'm receiving a 404 error, except on the my main URL? Can anyone give me any advice on how to do 301 redirect (For Dummies)? I'm worried I am going to kill the indexing I have already established with the major engines unless I act quick. Any help would be highly appreciated.

    Thanks, Erin
  • Jonathan
    Senior Member
    • Mar 2004
    • 1229

    #2
    PHP Code:
    <?php
    header
    ("HTTP/1.1 301 Moved Permanently");
    header("Location: http://www.newdomain.com/page.html");
    exit();
    ?>
    http://www.programmingforums.net/index.php?showtopic=32
    "How can someone be so distracted yet so focused?"
    - C

    Comment

    • erin
      Junior Member
      • May 2004
      • 5

      #3
      Boy, this is emabarrising...where in the html do I place the code?

      Comment

      • -Oz-
        Senior Member
        • Mar 2004
        • 545

        #4
        That is all you place in a page like whatever.php
        Dan Blomberg

        Comment

        • Skky
          Member
          • Apr 2004
          • 31

          #5
          You would need to replace your "whatever.php" at your old URL with that script (and only that script). Then, you just have to keep them there until you think that all the search engines have visited and updated their records.

          However there are several problems with this method.

          First of all, would you have to make a redirect script for every page at your former URL? That could be a real headache for a large website with a lot of pages.

          Also that script uses PHP, so your old server/location would need to:

          A: Be able to parse php files.
          B: All your files must have a .PHP ext (or otherwise be PHP-parsable)

          So, unless you mess with apache directives, that won't work for files with other extentions (.HTML, .ASP, ect). Are there other ways of doing this that doesn't present these issues? Perhaps a .HTACCESS solution?
          Last edited by Skky; 08-01-2004, 01:37 AM.

          Comment

          • Jonathan
            Senior Member
            • Mar 2004
            • 1229

            #6
            Since he said 'cPanel9' in the title, I'm sure he has PHP
            and doesn't have to worry about .ASP files
            "How can someone be so distracted yet so focused?"
            - C

            Comment

            • Skky
              Member
              • Apr 2004
              • 31

              #7
              Still, you would have to do that for every file on the site, which could be a lot of work for larger sites. I was searching around the 'net and found this claimed solution to the problem with just one .HTACCESS file in the root web directory. (haven't tested it at dathorn yet):

              Code:
              RewriteEngine On
              RewriteCond %{HTTP_HOST} ^yourdomain.com$ [OR]
              RewriteCond %{HTTP_HOST} ^www.yourdomain.com$
              
              RewriteRule ^(.*)$ [url]http://www.newlocation.com/[/url] [L,R=301]
              Orginal posting: http://liewcf.com/wp/archives/2004/0...o-new-website/


              (EDIT: Fixed script. Thanks Zenfort.)
              Last edited by Skky; 08-01-2004, 07:40 PM.

              Comment

              • zenfort
                Member
                • Mar 2004
                • 42

                #8
                I use this on cpanel09 to rewrite parked domains for SEO
                Code:
                RewriteEngine on
                RewriteCond %{HTTP_HOST} !^$
                RewriteCond %{HTTP_HOST} ^this\.com [OR]
                RewriteCond %{HTTP_HOST} ^www\.this\.com [OR]
                RewriteCond %{HTTP_HOST} ^andthis\.info [OR]
                RewriteCond %{HTTP_HOST} ^www\.andthis\.info
                RewriteRule ^(.*)$ http://www.that.com/$1 [R=301,L]
                No [OR] on the last RewriteCond.

                I use this to rewrite to another server from within a particular directory (music/ecgc):
                Code:
                Redirect /music/ecgc/index.html [url]http://www.somewhereelse.com/default.htm[/url]
                Redirect /music/ecgc/about.html [url]http://www.somewhereelse.com/default.htm[/url]
                Redirect /music/ecgc/ecgcnews.html [url]http://www.somewhereelse.com/default.htm[/url]
                Redirect /music/ecgc/ecgcphotos.html [url]http://www.somewhereelse.com/default.htm[/url]
                Redirect /music/ecgc/ecgcsounds.html [url]http://www.somewhereelse.com/default.htm[/url]
                Redirect /music/ecgc/links.html [url]http://www.somewhereelse.com/default.htm[/url]
                namaste
                Last edited by zenfort; 08-01-2004, 07:45 PM.

                Comment

                Working...