Jump to content

Help With Redirects


bluewaves

Recommended Posts

How do I set up a redirect?  I have some pages on my site that have two pages with essentially the same stuff on it.

I really should do a redirect on one of them. If people have bookmarked that url, will the redirect to the other page work without any harm?

 

I also have some html pages that I'd like to redirect to .php extensions.  I don't want to suffer any Google penalties for it though.

 

Does anyone feel confident in directing me?

 

Thanks!

Link to comment
Share on other sites

Use this function for redirects. You can call it via.. redirect("location.php"); This means you can use it anywhere. As it also uses a header if it hasn't been sent, else a js version/meta version.

 

function redirect($location) {
    if(!headers_sent()) :
        header('Location: ' . $location);
    else :
        echo '<script type="text/javascript">window.location.href="' . $location . '";</script>';
        echo '<noscript><meta http-equiv="refresh" content="0;url=' . $location . '" /></noscript>';
    endif;
}

 

Though for redirecting .html pages to .php, this would work for ALL .html pages in .HTACCESS

Options +FollowSymlinks
RewriteEngine on
RewriteRule ^(.*)\.html$ $1.php [NC]

 

Even for your first question, this can be used

Redirect 301 /oldpage.php http://www.example.com/newpage.php

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.