【问题标题】:htaccess permanent redirect and remove string from urlhtaccess 永久重定向并从 url 中删除字符串
【发布时间】:2013-10-02 01:48:37
【问题描述】:

在此示例中,如何让通过移动 url 进入网站的访问者被重定向到非移动 url;

用户访问http://website.com/*mobile/*the-page.html
将他们重定向到http://website.com/the-page.html

通过谷歌搜索,我想出了以下 htaccess 行:

RewriteRule ^/?mobile/(.*)$ /$1 [L,R=301]

虽然它正确地重定向到正确的页面,但它使用动态页面的文件名来这样做,例如:

http://website.com/index.php?id=the-page

我怎样才能让它从 url 中取出 mobile/?

【问题讨论】:

    标签: apache .htaccess mod-rewrite redirect


    【解决方案1】:

    好的,慢点...我需要删除移动网站的原始重写规则。

    之后,添加就很简单了

    RewriteRule ^mobile/(.*)$ /$1 [L,R=301]
    

    到 htaccess。

    【讨论】:

      猜你喜欢
      • 2016-11-05
      • 2016-10-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-01-10
      • 2018-06-04
      • 1970-01-01
      • 2020-10-04
      相关资源
      最近更新 更多