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..?



Ad: There You can have your forum site-wide banner/text ad for $19 monthly. Contact admin


jayakumari
 
Posts: 29
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


User avatar
hostingforum
Site Admin
 
Posts: 625
Joined: Fri May 20, 2011 7:58 pm
Location: Czech Republic

Re: How to create 301 Redirect code..?

Postby Jeffer » Tue Sep 13, 2016 10:29 am

Thank you a lot for the help! I am a beginner, and I've created my website with the help of a church WP theme I really want to make some money from it, so such litle tips will be helpful for me


Jeffer
 
Posts: 4
Joined: Tue Sep 13, 2016 10:21 am

Re: How to create 301 Redirect code..?

Postby pranu » Wed Sep 28, 2016 11:25 am

Thank you for the help. Its very important to add the 301 redirection, but we have to add it properly to get the result.


pranu
 
Posts: 11
Joined: Fri Apr 22, 2016 5:41 am


Return to General Webmaster Talk

Who is online

Users browsing this forum: No registered users and 0 guests


cron