<tfoot id='TT8pc'></tfoot>

<small id='TT8pc'></small><noframes id='TT8pc'>

<legend id='TT8pc'><style id='TT8pc'><dir id='TT8pc'><q id='TT8pc'></q></dir></style></legend>
        • <bdo id='TT8pc'></bdo><ul id='TT8pc'></ul>
      1. <i id='TT8pc'><tr id='TT8pc'><dt id='TT8pc'><q id='TT8pc'><span id='TT8pc'><b id='TT8pc'><form id='TT8pc'><ins id='TT8pc'></ins><ul id='TT8pc'></ul><sub id='TT8pc'></sub></form><legend id='TT8pc'></legend><bdo id='TT8pc'><pre id='TT8pc'><center id='TT8pc'></center></pre></bdo></b><th id='TT8pc'></th></span></q></dt></tr></i><div id='TT8pc'><tfoot id='TT8pc'></tfoot><dl id='TT8pc'><fieldset id='TT8pc'></fieldset></dl></div>

      2. 检查 cookie 并使用 Apache 重定向

        Check cookie and redirect with Apache(检查 cookie 并使用 Apache 重定向)

        <small id='eu4Tb'></small><noframes id='eu4Tb'>

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

            1. <legend id='eu4Tb'><style id='eu4Tb'><dir id='eu4Tb'><q id='eu4Tb'></q></dir></style></legend>
                  <tbody id='eu4Tb'></tbody>
                  本文介绍了检查 cookie 并使用 Apache 重定向的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我很想得到一些反馈.我不确定这是否是正确的方法.

                  I'd love to get some feedback on this. I'm not sure if it's the right approach.

                  详情

                  我使用 PHP 5.3/MySQL 4 运行 Apache 2,Drupal 6 是平台.

                  I'm running Apache 2 with PHP 5.3/MySQL 4 and Drupal 6 is the platform.

                  我正在开发一个网站,其中包含几个选定城市的餐厅评论.当用户到达站点时,它可以选择属于他们的城市.我将他们的选择存储在 cookie 中,如果他们没有做出选择,我会选择一个默认城市.

                  I'm developing a site which contains restaurant reviews in a couple of selected cities. When the users arrives at the site it can choose which city is theirs. I store their choice in a cookie and if they haven't made a choice I've selected a default city.

                  建议的解决方案

                  现在我希望 URL mydomain.com/reviews 根据他们的城市选择重定向到特定于城市的 URL.例如,如果我选择了巴黎作为我的城市,则 mydomain.com/reviews/paris.(如果没有设置 cookie,它应该重定向到默认城市.)

                  Now I want the URL mydomain.com/reviews to redirect to the city specific URL based on their city choice. For example mydomain.com/reviews/paris if I've selected Paris as my city. (If there's no cookie set it should redirect to the default city.)

                  我认为这是最好的选择,因为我希望用户能够在不更改城市的情况下查看其他城市的评论.如果他们想查看伦敦餐厅的评论,只需访问 mydomain.com/reviews/london.

                  I consider this the best alternative because I want the user to be able to see reviews in another city without changing their city. If they'd like to view reviews for London restaurant they can simply go to mydomain.com/reviews/london.

                  为了获得最佳性能,我正在考虑让 Apache 检查 cookie 并在用户访问 mydomain.com/reviews 时重定向到正确的城市.

                  For the best performance I'm thinking of having Apache check the cookie and make the redirect to the right city when the user goes to mydomain.com/reviews.

                  这里是我的问题……

                  1. 如何配置 Apache 以执行此操作?
                  2. 这是最好的方式吗?

                  推荐答案

                  1. 要配置 Apache 以执行此操作,请使用以下内容,替换为 cookie 名称.

                  1. To configure Apache to do this, use the following, replacing with the cookie name.

                  RewriteEngine on
                  RewriteCond %{REQUEST_URI} ^/reviews/?$
                  RewriteCond %{HTTP_COOKIE} <cookie>=([^;]+)
                  RewriteRule .* http://mydomain.com/reviews/%1 [R=302,L]
                  

                • Yelp 将位置存储在 cookie 中,所以我认为这是一个好兆头,因为他们有大量的流量并且看起来表现不错.

                • Yelp stores the location in a cookie, so I'd take that as a good sign, since they have a ton of traffic and appear to be doing well.

                  使用 Apache 进行重定向有利有弊,但主要的缺点是在代码中维护重写规则比在服务器上更容易.您可以快速进行修复和部署,而不必更改和重新启动所有 Apache 服务器.

                  There are pros and cons to using Apache to do the redirect, but the main con, is that it is easier to maintain the rewrite rule in your code instead of on the server. You can quickly make fixes and deploy, instead of having to change and restart all Apache servers.

                  这篇关于检查 cookie 并使用 Apache 重定向的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

                  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 的问题)
                  • <bdo id='DZ1OE'></bdo><ul id='DZ1OE'></ul>

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

                      <tfoot id='DZ1OE'></tfoot>
                    1. <legend id='DZ1OE'><style id='DZ1OE'><dir id='DZ1OE'><q id='DZ1OE'></q></dir></style></legend>
                      • <small id='DZ1OE'></small><noframes id='DZ1OE'>