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.