bluewaves Posted July 10, 2010 Share Posted July 10, 2010 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 https://forums.phpfreaks.com/topic/207379-help-with-redirects/ Share on other sites More sharing options...
XeNoMoRpH1030 Posted July 12, 2010 Share Posted July 12, 2010 The only HTML option is to use a meta refresh. <meta http-equiv="refresh" content="0;url=http://example.com/" /> There are of course other methods if you rather not use HTML, such as server side and Javascript. Link to comment https://forums.phpfreaks.com/topic/207379-help-with-redirects/#findComment-1084832 Share on other sites More sharing options...
haku Posted July 12, 2010 Share Posted July 12, 2010 .htaccess redirects Link to comment https://forums.phpfreaks.com/topic/207379-help-with-redirects/#findComment-1084955 Share on other sites More sharing options...
TeddyKiller Posted July 12, 2010 Share Posted July 12, 2010 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 https://forums.phpfreaks.com/topic/207379-help-with-redirects/#findComment-1084957 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.