Top Hosting Forum

WebHosting Reviews Forum

Budget DirectAdmin hosting and domain names

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 $99 yearly. Contact admin

Posts: 26
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:
header("Location: http://newpathhere");

other code here


It will serve as a 301 redirect. More reading:

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

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.

Posts: 7
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 @
Posts: 43
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