【问题标题】:How to redirect from example.com/path/file to http://example.com/path/file with htaccess?如何使用 htaccess 从 example.com/path/file 重定向到 http://example.com/path/file?
【发布时间】:2018-04-21 23:18:51
【问题描述】:

所以无论有没有路径,我都想将 example.com/* 重定向到 http://example.com/*

我听说拥有静态 URL 对 SEO 有好处,例如,如果访问者导航到 www.example.com/path 或只是 example.com/path,我会将他们重定向到 http://example.com/path

提前致谢。

【问题讨论】:

    标签: .htaccess http redirect


    【解决方案1】:

    我想这会对你有所帮助

    RewriteCond %{HTTPS} off
    RewriteCond %{HTTP_HOST} !^www\.
    RewriteRule ^ http://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
    
    RewriteCond %{HTTPS} on
    RewriteCond %{HTTP_HOST} ^www\.(.+)$
    RewriteRule ^ https://%1%{REQUEST_URI} [R=301,L]
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-09-21
      • 1970-01-01
      • 2011-12-13
      • 2014-10-17
      • 2015-05-21
      相关资源
      最近更新 更多