简体   繁体   English

htaccess-将当前文件修改为301,将所有流量重定向到https

[英]htaccess - modify current file to 301-redirect all traffic to https

this is my current .htaccess file: 这是我当前的.htaccess文件:

Options -Indexes FollowSymLinks Includes ExecCGI MultiViews
RewriteEngine On
RewriteCond %{HTTP_USER_AGENT}   (.*)ApacheBench(.*)    [NC]
RewriteRule ^(.*) - [F]
RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
RewriteRule .* h++p://%1%{REQUEST_URI} [R=301,L]
RewriteCond %{HTTP_HOST} ^seconddomain.com [NC,OR]
RewriteCond %{HTTP_HOST} ^www.seconddomain.com [NC]
RewriteRule ^(.*)$ h++p://firstdomain.com/path/to/somewhere [L,R=301,NC]

php_value memory_limit 512M
php_value max_input_vars 10000
php_value upload_max_filesize 5000M

What I want to do is, that all traffic coming to firstdomain.com to be redirected to https://firstdomain.com . 我想做的是,将所有进入firstdomain.com的流量都重定向到https://firstdomain.com

So: 所以:

  • h++p://firstdomain.com h ++ p://firstdomain.com
  • h++p://www.firstdomain.com h ++ p://www.firstdomain.com
  • h++ps://www.firstdomain.com h ++ ps://www.firstdomain.com

all should be redirected (301 redirect) to 所有都应重定向(301重定向)到

  • h++ps://firstdomain.com h ++ ps://firstdomain.com

How I need to modify it? 我该如何修改? I tried it myself already before, but then I always receive a redirect error that seems to be unable to end and therefor the browser stops resolving the domain then. 我以前已经尝试过该方法,但是随后我总是收到一个似乎无法结束的重定向错误,因此浏览器随后停止解析该域。

Options +FollowSymlinks
RewriteEngine on
ReWriteCond %{HTTP_HOST} ^(www.)?firstdomain.com$ [NC]
ReWriteRule ^(.*)$ https://seconddomain.com/$1 [R=301,L]

you can try it. 你可以试试。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM