301 Redirect in htaccess, PHP and IIS

hoangvu

New member
Joined
Jun 6, 2012
Messages
1,835
Points
0
Now I want to tell you in this article about redirects and how you can set this in 301 Redirect with htaccess, PHP and IIS.

There are different kinds of redirects but the redirect that gets the most attention and the most important for SEO is the 301 redirect. The 301 redirect is a permanent redirect, and will largely forward link value of the old page or domain. When you do not set or use a wrong redirect (for example, a 302 temporary redirect) the chances are that previous results will be lost.

A redirect from domain to domain (URL) but also within a domain.

301 Redirect. htaccess

A 301 redirect is set in the htaccess. The easiest way is to set a separate redirect rule for each redirect you want to make This can adjust the following line in the htaccess:

Code:
Redirect 301 /forum.php https://www.webmastersun.com/index.php
Is important here is that no domain at the old location is named but only what is behind the domain. At the new location, the new URL.

When you have a new website, I can imagine that the establishment of separate lines per redirect a lot of work. It is also possible to a large group of redirects through a RewriteRule
Code:
RewriteEngine on
RewriteCond% {HTTP_HOST} ^ ([^:] + \.) * Old-domain \ en \. (: [0-9] *) $ [NC]?
RewriteRule ^ / (*) $ https://www.webmastersun.com/ $ 1 [R = 301, L]
301 Redirect in PHP

In addition to the widely used method to perform a redirect via htaccess is also possible to redirect in PHP. This happens on the page that loads. So if you want to remove the page from your system can not use this option.

Put the following code on the page ( example: www.webmastersun.com / old page .php ).

Code:
<? Php
header ("HTTP/1.1 301 Moved Permanently");
header ("Location: https://www.webmastersun.com/forums/10-Search-Engine-Optimization");
>
301 Redirect in IIS

When your website is hosted on an IIS (Windows) server then set up a 301 redirect like anything else. To do this you follow the following 5 steps.

- Open Internet Services Manager and click the right mouse button on the file you want to redirect and go to the tab "Home Directory".
- Select the "A redirection to a URL.
- Type the new location.
- Check "The exact URL entered" and "A permanent redirection for this resource.
- Then click on 'Apply'.

Other 301 Redirects

There are several options for implementing a 301 redirect. But please note that not all ways of redirecting the value of the old location to the new location. My advice is when to make use of the above ways.

Limit on the number of 301 Redirects?

There is no limit on the number of redirects that link from the old location to the new location of the website. Or is there a limit on the number of redirects that are connected, because a search engine after a number of stops to be redirected with a redirect. It is good when you set up a redirect of a page to see if you need to adjust an old redirect.

For example:
- Page A refers to Page B.
- There comes a Page C.
- ERROR: Page A refers to Page B and Page B refers to Page C.
- GOOD: page A and page B to page C.

Hopefully you can get started with the setup of your 301 redirects for your website. :rasta: :phone: me if you have got any problems :smart:
 
Older threads
Replies
23
Views
9,757
Replies
0
Views
2,087
Replies
3
Views
2,823
Newer threads
Latest threads
Recommended threads
Replies
6
Views
3,103
Replies
2
Views
3,887
arorastat3456
  • Locked
Replies
2
Views
4,388
Replies
3
Views
3,249

Referral contests

Referral link for :

Sponsors

Popular tags

You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an alternative browser.

Top