<legend id='3rbg7'><style id='3rbg7'><dir id='3rbg7'><q id='3rbg7'></q></dir></style></legend>

<small id='3rbg7'></small><noframes id='3rbg7'>

  • <i id='3rbg7'><tr id='3rbg7'><dt id='3rbg7'><q id='3rbg7'><span id='3rbg7'><b id='3rbg7'><form id='3rbg7'><ins id='3rbg7'></ins><ul id='3rbg7'></ul><sub id='3rbg7'></sub></form><legend id='3rbg7'></legend><bdo id='3rbg7'><pre id='3rbg7'><center id='3rbg7'></center></pre></bdo></b><th id='3rbg7'></th></span></q></dt></tr></i><div id='3rbg7'><tfoot id='3rbg7'></tfoot><dl id='3rbg7'><fieldset id='3rbg7'></fieldset></dl></div>

        <bdo id='3rbg7'></bdo><ul id='3rbg7'></ul>

        <tfoot id='3rbg7'></tfoot>

        SEO 友好 URL 而不是查询字符串 .htaccess

        SEO friendly URL instead of query string .htaccess(SEO 友好 URL 而不是查询字符串 .htaccess)

        <small id='9Nzn1'></small><noframes id='9Nzn1'>

          <bdo id='9Nzn1'></bdo><ul id='9Nzn1'></ul>

        • <tfoot id='9Nzn1'></tfoot>

          <legend id='9Nzn1'><style id='9Nzn1'><dir id='9Nzn1'><q id='9Nzn1'></q></dir></style></legend>
            <tbody id='9Nzn1'></tbody>

            <i id='9Nzn1'><tr id='9Nzn1'><dt id='9Nzn1'><q id='9Nzn1'><span id='9Nzn1'><b id='9Nzn1'><form id='9Nzn1'><ins id='9Nzn1'></ins><ul id='9Nzn1'></ul><sub id='9Nzn1'></sub></form><legend id='9Nzn1'></legend><bdo id='9Nzn1'><pre id='9Nzn1'><center id='9Nzn1'></center></pre></bdo></b><th id='9Nzn1'></th></span></q></dt></tr></i><div id='9Nzn1'><tfoot id='9Nzn1'></tfoot><dl id='9Nzn1'><fieldset id='9Nzn1'></fieldset></dl></div>
                  本文介绍了SEO 友好 URL 而不是查询字符串 .htaccess的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  如何修改 .htaccess 文件并获取 SEO 友好的 URL 而不是查询字符串.我想实现这三个目标:

                  How can I modify the .htaccess file and get SEO friendly URLS instead of a query string. I want to achieve this 3 goals:

                  1. localhost/example/products/ 而不是localhost/example/products-list.php
                  2. localhost/example/products/38/ 而不是localhost/example/products.php?id=38
                  3. localhost/example/products/38/red/ 而不是localhost/example/products.php?id=38&color=red
                  1. localhost/example/products/ instead of localhost/example/products-list.php
                  2. localhost/example/products/38/ instead of localhost/example/products.php?id=38
                  3. localhost/example/products/38/red/ instead of localhost/example/products.php?id=38&color=red

                  在另一篇文章中@anubhava 帮了我很多,这就是我现在所拥有的第二点:

                  On another post @anubhava helped me a lot and this is what I have right now for the second point:

                  RewriteEngine on
                  RewriteBase /example
                  # external redirect from actual URL to pretty one
                  RewriteCond %{THE_REQUEST} /products(?:.php)??id=([^s&]+) [NC]
                  RewriteRule ^ products/%1? [R=302,L,NE]
                  # internal forward from pretty URL to actual one
                  RewriteCond %{REQUEST_FILENAME} !-d
                  RewriteCond %{REQUEST_FILENAME} !-f
                  RewriteRule ^products/([^/]+)/?$ products.php?id=$1 [L,QSA]
                  

                  第二点工作正常,但我想知道我必须把其他规则放在哪里,之前还是之后.我把它放在另一个规则之后,但它不起作用,因为它重定向到以前的 url localhost/example/products/38/:

                  The second point works properly but I want to know where do I have to put the other rules, before or after. I put this right after the other rule, but it's not working because it redirects to the previous url localhost/example/products/38/:

                  # external redirect from actual URL to pretty one
                  RewriteCond %{THE_REQUEST} /products(?:.php)??id=([^s&]+)?color=([^s&]+) [NC]
                  RewriteRule ^ products/%1/%2? [R=302,L,NE]
                  # internal forward from pretty URL to actual one
                  RewriteCond %{REQUEST_FILENAME} !-d
                  RewriteCond %{REQUEST_FILENAME} !-f
                  RewriteRule ^products/([^/]+)/([^/]+)/?$ products.php?id=$1&color=$2 [L,QSA]
                  

                  推荐答案

                  您需要一组新的 2 个参数规则:

                  You need new set of rules for 2 parameters:

                  RewriteEngine on
                  RewriteBase /example/
                  
                  # external redirect from actual URL to pretty one
                  RewriteCond %{THE_REQUEST} /products(?:.php)??id=([^s&]+)&color=([^s&]+) [NC]
                  RewriteRule ^ products/%1/%2/? [R=302,L,NE]
                  
                  RewriteCond %{THE_REQUEST} /products(?:.php)??id=([^s&]+)s [NC]
                  RewriteRule ^ products/%1/? [R=302,L,NE]
                  
                  RewriteCond %{REQUEST_FILENAME} -d [OR]
                  RewriteCond %{REQUEST_FILENAME} -f
                  RewriteRule ^ - [L]
                  
                  # internal forward from pretty URL to actual one
                  RewriteRule ^products/([^/]+)/?$ products.php?id=$1 [NC,L,QSA]
                  
                  RewriteRule ^products/([^/]+)/([^/]+)/?$ products.php?id=$1&color=$2 [NC,L,QSA]
                  
                  RewriteRule ^products/?$ products-list.php [L,NC]
                  

                  这篇关于SEO 友好 URL 而不是查询字符串 .htaccess的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  DeepL的翻译效果还是很强大的,如果我们要用php实现DeepL翻译调用,该怎么办呢?以下是代码示例,希望能够帮到需要的朋友。 在这里需要注意,这个DeepL的账户和api申请比较难,不支持中国大陆申请,需要拥有香港或者海外信用卡才行,没账号的话,目前某宝可以
                  PHP通过phpspreadsheet导入Excel日期,导入系统后,全部变为了4开头的几位数字,这是为什么呢?原因很简单,将Excel的时间设置问文本,我们就能看到该日期本来的数值,上图对应的数值为: 要怎么解决呢?进行数据转换就行,这里可以封装方法,或者用第三方的
                  mediatemple - can#39;t send email using codeigniter(mediatemple - 无法使用 codeigniter 发送电子邮件)
                  Laravel Gmail Configuration Error(Laravel Gmail 配置错误)
                  Problem with using PHPMailer for SMTP(将 PHPMailer 用于 SMTP 的问题)
                  Issue on how to setup SMTP using PHPMailer in GoDaddy server(关于如何在 GoDaddy 服务器中使用 PHPMailer 设置 SMTP 的问题)
                • <small id='hk7H5'></small><noframes id='hk7H5'>

                    <tbody id='hk7H5'></tbody>
                • <legend id='hk7H5'><style id='hk7H5'><dir id='hk7H5'><q id='hk7H5'></q></dir></style></legend>

                        <bdo id='hk7H5'></bdo><ul id='hk7H5'></ul>
                            <i id='hk7H5'><tr id='hk7H5'><dt id='hk7H5'><q id='hk7H5'><span id='hk7H5'><b id='hk7H5'><form id='hk7H5'><ins id='hk7H5'></ins><ul id='hk7H5'></ul><sub id='hk7H5'></sub></form><legend id='hk7H5'></legend><bdo id='hk7H5'><pre id='hk7H5'><center id='hk7H5'></center></pre></bdo></b><th id='hk7H5'></th></span></q></dt></tr></i><div id='hk7H5'><tfoot id='hk7H5'></tfoot><dl id='hk7H5'><fieldset id='hk7H5'></fieldset></dl></div>
                            <tfoot id='hk7H5'></tfoot>