【问题标题】:How to Redirect Specific Page to Error page using HTACCESS如何使用 HTACCESS 将特定页面重定向到错误页面
【发布时间】:2021-12-20 14:14:50
【问题描述】:

我有如下的 htaccess 文件

RewriteEngine On
RewriteCond %{HTTP_USER_AGENT} "android|blackberry|iphone|ipod|iemobile" [NC]
RewriteCond ^ https://example.com/fernando/n-page.html [NC]
RewriteRule ^ https://example.com/fernando/error.php [R,L]

如果 n-page.html,我要查找的内容,检查用户是否来自移动设备,如果从移动设备重定向到错误页面,如果来自桌面,则无事可做,如果其他页面,我不想做任何事情。我正在尝试移动检查工作正常,只是无法检查其是否为 n-page.html。让我知道这里是否有人可以帮助我解决问题。 谢谢!

【问题讨论】:

    标签: apache .htaccess mod-rewrite


    【解决方案1】:

    改为这样:

    RewriteCond %{HTTP_USER_AGENT} "android|blackberry|iphone|ipod|iemobile" [NC]
    RewriteRule ^fernando/n-page\.html$ /fernando/error.php [R,L]
    

    上述声明:如果请求是针对fernando/n-page.html(无斜线前缀)并且具有移动用户代理,则重定向到/fernando/error.php。这是一个 302(临时)重定向。

    参考:

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-08-16
      • 2017-08-16
      • 1970-01-01
      • 2018-04-18
      相关资源
      最近更新 更多