PHP implements 301 permanent redirection. This article introduces how PHP implements 301 permanent redirection to direct a domain name without www to a domain name with www. When your site domain name changes or the webpage address changes (this article describes how to implement 301 permanent redirection in PHP to direct a domain name without www to a domain nam
Php program website 301 jump method first jump code Jump Code first
$ Dest_host = "www.99downs.com"; // declare a variable $ dest_host to store the URL to jump.
$ Url = $ _ SERVER ['request _ URI ']; // declare a variable $ url to store the host address and url of the current website.
$ Http = (isset ($ _ SERVER ['https']) $ _ SERVER ['https']! = 'Off ')? 'Https: // ': 'http: //'; // declare the variable $ http storage protocol
// $ Port = $ _ SERVE
Header ("http/1.1 301 Moved permanently");
Header ("location:http://www.example.com/newpage/");
Exit
?>
Copy CodePHP 301 for IIS:
Header ("status:301 Moved permanently");
Header ("location:http://www.example.com/newpage/");
Exit
?>
Copy CodeFor more information on PHP
Some friends may use the method of comparing benzene, add Response.redirectpermanent method under each Controller. The simpler approach is to add the following code to the Global.axax.cs:
The code is as follows
Copy Code
protected void Application_BeginRequest (object sender, EventArgs e){String strurl = Request.Url.ToString (). Trim (). ToLower ();if (Strurl.contains ("Http://111cn.net")){Response.redirectpermanent ("Http://www.111cn.net"); Not good}}
If y
Tomcat makes 301 turns
Check a lot, the most standard practice on Linux installed Apache or Nginx, using Tomcat to map Jsp;nginx or Apache to set redirection.
Here are some of the redirects implemented on the page
=========================== Blog ===========================
So on the tomcat+jsp site, 301 redirects how to do it. Webmaster know: From the SEO point of view, when the domain name of the site
If your page appears 301 or 404 for the user experience is a very serious problem, so we do php header301 or 404 must be careful and careful, and I came to see.
301 Jump
The code is as follows
Copy Code
Header (' http/1.1 301 Moved permanently ');Header (' location:http://www.abc.com/aaa/');Exit ();
Do not miss the header (' h
HTTP status: 202, 301, 304, 404, 503 reprinted Baidu... 301, 404, 200, 304, and other HTTP status, what does it mean?
In the practical application of website construction, many small mistakes may occur, just as MySQL was not optimized at the beginning, affecting the overall browsing effect of the website. In fact, the regular HTTP status code of a website is the same. Google cannot verify the website in se
This article introduces how PHP implements 301 permanent redirection to direct a domain name without www to a domain name with www, the implementation method is as follows: when your site domain name changes or the webpage address changes (the webpage storage directory or the webpage file name changes), how to ensure that the site
This article introduces how PHP implements 301 permanent redirection to direc
I. This method is recommended because it transfers all the original URLs of www.111cn.net to the new address of 111cn.net. The code is as follows:Copy code $ The_host = $ _ SERVER ['http _ host'];$ Request_uri = isset ($ _ SERVER ['request _ URI '])? $ _ SERVER ['request _ URI ']: '';If ($ the_host = 'www .111cn.net '){Header ('http/1.1 301 Moved Permanently ');Header ('Location: http://111cn.net
It's depressing, but the good news is that Google has been tested. Below I send the record to give everybody the reference, hoped has the help.
No. 4-8
Site snapshot update to number 4-7, but included did not increase, ranking unchanged. The old web site is not affected.
No. 4-9
Snapshots of the site to update to 4-8, included unchanged (5), the chain increased, the ranking has not changed, the old site ranking is still in.
Number 4-10 (max change)
Snapshots of the site to update to 4-9, i
The difference between HTTP status Codes 301 and 302 and enterprise application cases1. What is 301 redirect?301 Redirect/Jump generally means that this page is permanently transferred to another address.301 is a permanent transfer (permanently Moved), SEO commonly used moves, will be the old page of PR and other infor
Jump of Status Code 200: 1. metahttp-equivrefreshcontent3. URLdefault. aspx2.Server. transfer (default. aspx); 3. URLRewrite-strictly speaking, this is not a jump, but a jump in URL spoofing status 302: Response. redirect (default. aspx); Status 301 and
Jump of Status Code 200: 1. meta http-equiv = "refresh" content = "3; URL = default. aspx "/2. server. transfer ("default. aspx "); 3. URLRewrite-strictly speaking, this is not a jump, but a jump in UR
At present, the general space supports htaccess 301 redirection, but many friends do not know how to correctly implement htaccess 301 redirection. I will share with you a piece of correct code.
The Code is as follows:
Copy code
RewriteEngine onRewriteCond % {HTTP_HOST} ^ (bKjia. c0m) (: 80 )? [NC]RewriteRule ^ (. *) http://www.bKjia. c0m/$1 [R =
The method of editing. htaccess.Note: Be sure to back up the. htaccess file in the corresponding directory before you set 301 redirection.1. redirect 111cn.net to Www.111cn.netThis redirect is designed to make the domain name unique, is the website SEO tutorial must do, back redirect www.111cn.net to 111cn.net is also for the same reason, but the form is different.Open the. htaccess file and add the following rules. (The following rule is for the prim
What is the difference between 301 and 302 HTTP status?301,302 is the encoding of the HTTP state, which means that a URL has been shifted, except that:301 redirect:301 Represents a permanent transfer (permanently Moved),302 redirect:302 represents a temporary transfer (temporarily Moved),Of course Http Status 200 indicates that no problems occurred.What are the b
The difference between HTTP status Codes 301 and 302 and enterprise application casesOriginal: http://blog.51cto.com/oldboy/17742601. What is 301 redirect?301 Redirect/Jump generally means that this page is permanently transferred to another address.301 is a permanent transfer (permanently Moved), SEO commonly used mov
The website replaces the domain name, uses the old domain name 301 to refer to the new domain name.
Setting the URL permanently from IIS can be, it looks easy, and it takes a while to discover that the parameters are not on.
From the Microsoft website to find the following instructions, sure enough:IIS 301 Redirection SettingsIt is more convenient to use this time to set IIS redirection. Here is the IIS r
To achieve 301 page jump before you need to make changes to the Apache configuration such as
Apache does not open the Mod_rewrite module by default,
1, will
The code is as follows
Copy Code
#LoadModule Rewrite_module modules/mod_rewrite.so
This line is preceded by the # number removed, http.conf Site directory configuration, the other is the space users commonly used
To
The code is as follows
Note: Be sure to back up the. htaccess file in the corresponding directory before you set 301 redirection.
1.301 redirect b.org to www.b.orgThis redirect is designed to make the domain name unique, is the website SEO must do, the back redirects www.b.org to b.org is also for the same reason, but the form is different.
Open the. htaccess file and add the following rules. (The following rule is for the primary domain name, and the subdomain is to be m
301 Steering Definition301 Turn (or call 301 Redirect, 301 jump) is one of the status codes in the header information (header) in the HTTP data stream returned by the server when the user or search engine sends a browse request to the Web server, indicating that this page is permanently transferred to another address.Other common status code also includes, 200 me
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.