Dynamic address rewrite Pseudo-static, and then 301 jump to pseudo-static dead loop solution

Source: Internet
Author: User

Problem background: What are the historical issues left by the mine Secretary network? At the beginning, some dynamic pages were used due to various problems? Id = parameter format. It is unfriendly to seo/seo.html "target =" _ blank "> Search Engines. It is often considered to be pseudo-static. We advise webmasters to try to use pseudo static data as much as possible when creating new sites, not only for search engines, but also for user experience.

Problem Description: need to set/news/show_news.php? The address in the id = 1 format is in the/news/1 format, and/news/show_news.php? Id = 1 open in the browser to jump to/news/1 in 301.

However, when a rule is added to. htaccess, an endless loop occurs. The following are the rules for an endless loop:

The code is as follows: Copy code

RewriteRule ^ (d +) $/news/show_news.php? Id = $1 [L]

RewriteCond % {QUERY_STRING} ^ id = (d +) $ [NC]
RewriteRule ^ show_news.php $/news/% 1? [L, R = 301]

Cause of endless loops:/news/show_news.php? Id = 1 jump to/news/1, and/news/1 is rewritten as/news/show_news.php? Id = 1,/news/show_news.php? Id = 1 jump to/news/1 again, this way, burst into tears!

Solution: as long as a constant parameter is added during rewrite, the url is different from the 301 url,The rules are as follows:

The code is as follows: Copy code

RewriteRule ^ (d +) $/news/show_news.php? Id = $1 & r = 1 [L]

RewriteCond % {QUERY_STRING} ^ id = (d +) $ [NC]
RewriteRule ^ show_news.php $/news/% 1? [L, R = 301]

Finally solved the problem ......

The above is a real case. The environment is apache.

Related Article

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.