Top Hosting Forum

WebHosting Reviews Forum


How to create 301 Redirect code..?

General Webmaster Discussion @ Top Hosting Forum
Hosting Forum Description
General Webmaster Discussion at Top Hosting Forum, Welcome

How to create 301 Redirect code..?

Postby jayakumari » Mon Aug 29, 2016 7:49 am

Hello friends,

How to create 301 Redirect code..?



jayakumari
 
Posts: 27
Joined: Wed Feb 04, 2015 10:06 am

Re: How to create 301 Redirect code..?

Postby hostingforum » Tue Sep 06, 2016 2:27 pm

By editting .htaccess file (If you run Apache server) in your website root directory (www, public_html)
Add lines like:

//301 Redirect Old File
Redirect 301 /yourdirectory/yourfile.php /yourdirectory/yournewfile.php

//301 Redirect Entire Directory
RedirectMatch 301 /olddir(.*) /newdir/$1


Or google: 301 redirect htaccess

========== method 2:

You can also redirect inside a .php file by adding on the top (after <?php) this line so the php file looks like:
<?php
header("Location: http://newpathhere");
exit;

other code here

?>


It will serve as a 301 redirect. More reading: https://secure.php.net/manual/en/function.header.php


hostingforum
Site Admin
 
Posts: 662
Joined: Fri May 20, 2011 7:58 pm

Re: How to create 301 Redirect code..?

Postby unlockiphonese » Fri Sep 30, 2016 6:14 am

Simple 301 Redirects provides an easy method of redirecting requests to another page on your site or elsewhere on the web. It's especially handy when you migrate a site to WordPress and can't preserve your URL structure.


unlockiphonese
 
Posts: 6
Joined: Mon Aug 15, 2016 8:56 am
Location: singapore

Re: How to create 301 Redirect code..?

Postby Talinhuu » Mon Apr 29, 2019 2:37 am

You can simply install Htaccess editor plugin to edit htaccess file and insert 301 redirects codes for your site.


WordPress Tips & Tutorials @ WPGuideline.com
Talinhuu
 
Posts: 41
Joined: Wed Aug 22, 2018 6:58 am


Return to General Webmaster Talk

Who is online

Users browsing this forum: No registered users and 0 guests

.
cron