htaccess规则相应的HTTP链接

htaccess规则相应的HTTP链接

本文介绍了的.htaccess规则相应的HTTP链接,HTTP和HTTPS重定向到HTTPS?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时删除!!

首先,这里的htaccess的规则,我目前使用的:

 选项+了FollowSymLinks
RewriteEngine叙述上
重写规则(。*)http://example.com/$1 [R = 301,L]
 

这是伟大的,我重定向旧域到新的领域非常各个环节的每一个环节。也就是说, http://olddomain.com/1.html 将被重定向到 http://example.com/1.html 等等。

不过,这并不重定向 https://olddomain.com/1.html https://example.com/1。 HTML

和只是让你知道我试过了,下面是规则我也正好考验。不幸的是,他们正在创造某种循环,重定向不起作用。

 选项+了FollowSymLinks
RewriteEngine叙述上
重写规则(。*)example.com/$1 [R = 301,L]
 

 选项+了FollowSymLinks
RewriteEngine叙述上
的RewriteCond%{SERVER_PORT} ^ 443 $ [OR]
的RewriteCond%{} HTTPS = ON
重写规则(。*)example.com/$1 [R = 301,L]
 

所以,有人可以给我的规则重定向HTTP页面,HTTP和HTTPS网页为https?谢谢你。

解决方案

 #如果HTTPS上
的RewriteCond%{} HTTPS上
重写规则^(。*)$ https://example.com/$1 [R = 301,L]
#其他
重写规则^(。*)$ http://example.com/$1 [R = 301,L]
 

First, here's the .htaccess rule I currently use:

Options +FollowSymLinks
RewriteEngine on
RewriteRule (.*) http://example.com/$1 [R=301,L]

This is great, and redirects every link of my old domain to the very respective link in new domain. That is, http://olddomain.com/1.html is redirected to http://example.com/1.html and so forth.

But it doesn't redirect https://olddomain.com/1.html to https://example.com/1.html

And just so you know I tried, below are the rules I also happened to test. Unfortunately they're creating some kind of loop, and the redirection doesn't work.

Options +FollowSymLinks
RewriteEngine on
RewriteRule (.*) example.com/$1 [R=301,L]

and

Options +FollowSymLinks
RewriteEngine on
RewriteCond %{SERVER_PORT} ^443$ [OR]
RewriteCond %{HTTPS} =on
RewriteRule (.*) example.com/$1 [R=301,L]

So, can someone give me the rules redirect http pages to http and https pages to https? Thanks.

解决方案
#if https on
RewriteCond %{HTTPS} on
RewriteRule ^(.*)$ https://example.com/$1 [R=301,L]
#else
RewriteRule ^(.*)$ http://example.com/$1 [R=301,L]

这篇关于的.htaccess规则相应的HTTP链接,HTTP和HTTPS重定向到HTTPS?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

1403页,肝出来的..

09-06 23:31