How to deeply analyze the pseudo-static URL to remove index.php

Source: Internet
Author: User

Intermediary transaction http://www.aliyun.com/zixun/aggregation/6858.html ">seo diagnose Taobao guest cloud host technology Hall

As a seoer definitely know in the website optimization, SEO optimization is the need to optimize the URL, about WordPress, W host URL pseudo static method some time ago I have mentioned that The reason for this is to analyze some of the drawbacks of the methods mentioned above, and to revise the methods mentioned above for the removal of index.php.

The URL removes the index by adding a 404 page to apply a guideline to the URL. The online view of this method is mostly try not to use the argument, but I used a period of time to think this method is OK, this method will not only cut short URLs will basically save a website 404 page of the production of this step.

Since the beginning of this site is not very soon at first the article is not found in the previous installation methods have any drawbacks, but with the continuous updating of the article, the author finally found that through the 404 page to implement the URL pseudo static method will make the homepage of the page function can not be used. The author thought that the optimization of their own website has been almost did not expect to start the external link optimization when the URL to optimize the problem. Specific questions: Go to the homepage of the blog.***.com site to find the page directly to the page to find pages directly from the first to turn? (any page) Yes, but what if you want to get out of it? (any page) turn to other pages but not, page links will also appear some confusion phenomenon.

At first encountered this now let me confused, I do not know where to start the analysis for a long time, and finally must be the 404 page of the code has problems, this began the search information work. After repeated test summary, finally learned that the 404.php code is not complete enough to have a lot of loopholes. Attached source code screenshot:

So how do we correct this code? You're not going to write it, are you? Don't worry, you don't need to write it yourself, now I copy the code as follows:

< PHP

This is the default file for the site. Usually index.php

$default = ' index.php ';

The name of this file.

Set This value is the URL in Custom Error Properties of your website in IIS.

Goto:iis Manager > Websites > [Site Name] > Properties > Custom Errors >

404 & 404;2 & 404;3 > URL (Requires a '/' prefix in IIS).

$thisfile = ' 404-handler.php ';

$_server[' orig_path_translated '] = Str_replace ($thisfile, $default, $_server[' orig_path_translated '));

$_server[' script_filename '] = Str_replace ($thisfile, $default, $_server[' script_filename '));

$_server[' orig_path_info '] = Str_replace ($thisfile, $default, $_server[' orig_path_info '));

$_server[' script_name '] = Str_replace ($thisfile, $default, $_server[' script_name '));

$_server[' php_self '] = Str_replace ($thisfile, $default, $_server[' php_self '));

$_server[' path_info ' = false;

$qs =& $_server[' query_string '];

$ru =& $_server[' Request_uri '];

$pos = Strrpos ($qs, '://');

$pos = Strpos ($qs, '/', $pos + 4);

$_server[' URL ' = $ru = substr ($qs, $pos);

$qs = Trim (Stristr ($ru, '? '), '? ');

Required for WordPress 2.8+

$_server[' http_x_original_url ' = $ru;

Fix Get VARs

foreach ($_get as $var => $val) {

if (substr ($var, 0, 3) = = 404′) {

if (Strstr ($var, '? ')) {

$newvar = substr ($var, Strpos ($var, '? ') + 1);

$_get[$newvar] = $val;

}

Unset ($_get[$var]);

}

Break;

}

Include ($default);

? >

Just rebuild a text document and rename it to 404.php, and then upload it to the site root directory with your FTP. Dalian SEO http://blog.zzzuo.com Original reprint please specify.

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.