【问题标题】:.htaccess redirect wordpress.htaccess 重定向 wordpress
【发布时间】:2014-03-07 02:11:16
【问题描述】:

我有一个 wordpress 设置,我现在要托管一个支付门户

我只想重定向所有包含单词 training 的 url

我的 .htaccess 文件中有这些规则,但它们不起作用

RewriteCond %{REQUEST_URI} training
RewriteRule https://{HTTP_HOST}%{REQUEST_URI} [R=301,L]

只是要清楚不要查询字符串参数。但是网址的一部分 例如

www.abc.com/training/ should got to https://www.abc.com/training/

www.abc.com/training/test123/ should got to https://www.abc.com/trainig/test123/

【问题讨论】:

    标签: wordpress apache .htaccess redirect


    【解决方案1】:

    您在{HTTP_HOST} 之前缺少一个%,它将是这样的:

    RewriteCond %{HTTPS} !=on
    RewriteRule ^training/(.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L,QSA]
    

    【讨论】:

      【解决方案2】:

      我想这就是你要找的东西:

      RewriteEngine On
      RewriteBase /
      RewriteCond %{REQUEST_URI} training [NC]
      RewriteRule ^(?:http[s]?:\/\/)?(.*)$ https://$1 [R=301,L]
      

      不幸的是,这个世界远非完美,并且没有可靠的 mod_rewrite 在线测试工具,所以最后一行可能会有所不同:

      RewriteRule ^(?:http[s]?:\/\/)?(.*)$ https://%1/$1 [R=301,L]
      

      【讨论】:

      • 将在某个时候测试并通知您
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-10-06
      • 2016-12-28
      • 2013-02-28
      • 2015-01-29
      • 2013-09-22
      • 1970-01-01
      相关资源
      最近更新 更多