PHP is redirected from a level two directory to a first-level directory

Source: Internet
Author: User
Site migration, before the site is a level two directory, and now to move to a level directory, but before the two level catalog contains a lot of pages, how to use PHP to redirect the two-level directory page to the first level directory? The parameters are the same!
Previously included pages are http://www.caihua.cc/gouwu/cat/3/44/44935 redirected to http://www.caihua.cc/cat/3/44/44935 via PHP


Reply to discussion (solution)

This time with the address rewrite function ...

This time with the address rewrite function ...
Can you post the code? Thank you

Please ask ~! What is the role of sub-catalogue???

See these online:

SEO Note points

1, the directory should not be too deep, 2-3-level directory is preferred.

2, the contents of each directory should be strictly separated,

3, if a complete Web site system in a level directory, such as Bbs,blog,sns, then after a long time or stability, the search engine will consider this directory as a complete site.

4, the same website, such as BBS, put a directory and root directory, Google there, there is no advantage on the too big difference. But Baidu often gives the two level of the weight of the directory is relatively low.

5, the appropriate level of the directory, the main domain can provide a large amount of content, thereby increasing the primary domain weight.

The relationship between the sub-directory and the search ~!!!! And the relationship with the code, ~!!. Can you explain it a little bit??? !

Add the following in your location code:

$urlold = "http://www.caihua.cc/gouwu/cat/3/44/44935";//Your code assembly variables
$urlnew =str_replace ('/gouwu/', '/', $urlold);
Header ("Location: $urlnew");

Rewriterule/(. *)/(. *)/(. *)/(. *)/(. *)/$2/$3/$4/$5/[n,i]
Give it a try.

Add the following in your location code:


$urlold = "http://www.caihua.cc/gouwu/cat/3/44/44935";//Your code assembly variables

$urlnew =str_replace ('/gouwu/', '/', $urlold);

Header ("Location: $urlnew");

Thank you

Change it a little bit.

$urlold = isset ($_server[' Request_uri ')? $_server[' Request_uri ': ';//Your code assembles variable $urlnew=str_replace ('/gouwu/', '/', $urlold); header (' http/1.1 301 Moved Permanently ');//Issue 301 Header Header ("Location: $urlnew");

Indeed, forget the condition to judge.

  • Contact Us

    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.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.