重写HTTP到HTTPS仅使用的.htaccess一些网页(Rewrite http to https on some pages only using .htaccess)

   IT问题网   2018-05-08 00:00:00

问 题

我知道有关于我的问题很多主题。我检查了所有的,并试图出来,但不能使它发挥作用。 我需要重写http到https上只有一些网页。之后参观https网页的url会回到http。 这是我到目前为止有:

 
#重写规则为domain.com
rewriteengine叙述上
的rewritebase /

#rewrite www为domain.com
的rewritecond%{http_host} ^ www \。域\ .com [nc]
重写规则^(。*)$ http://domain.com/$1 [l,r = 301]

#rewrite到https
的rewritecond%{} https关闭
的rewritecond%{request_uri} /secure.php
(。*)重写规则的https://%{http_host}%{request_uri} [l]

#traffic到http://,除了secure.php
的rewritecond%{} https关闭
的rewritecond%{request_uri} /secure.php
(。*)重写规则的https://%{http_host}%{request_uri} [l]
 

当我跳过最后一组规则(流量为http://,除了secure.php)的secure.php页面加载的https和加密。精细。随着最后一组规则(流量为http://,secure.php除外)的url改写为https,变成蓝色(ssl)如属第二和消失(无ssl),但该网址仍是https

你知道吗? 亚采

解决方案

有与第三组规则的错误。 这里的解决方案:第3集的规则:如果https是"上",那么如果url中不包含"/安全",然后重定向到http。

 #重写domain.com的规则
rewriteengine叙述上
的rewritebase /

#rewrite www为domain.com
的rewritecond%{http_host} ^ www \。域\ .com [nc]
重写规则^(。*)$ http://domain.com/$1 [l,r = 301]

#rewrite到https
的rewritecond%{} https关闭
的rewritecond%{request_uri} /secure.php
(。*)重写规则的https://%{http_host}%{request_uri} [l]

#traffic到http://,除了secure.php
的rewritecond%{} https上
的rewritecond%{request_uri}!(/ secure.php)
(。*)重写规则的http:// {%http_host}%{request_uri} [l]
 

题外话建议:请认准雅虎慢的网站优化的他们非常聪明的建议,你就会明白为什么它总是最好有"www"的了。你最好做相反的你#1重写规则:如果没有"www",然后将其添加


请尝试使用 rewritelog 指令:它可以帮助您追踪到这样的问题:

 #跟踪:
#文件中获取大的快速,删除督促环境(!):
rewritelog"/web/logs/mywebsite.rewrite.log"
rewriteloglevel 9
rewriteengine叙述上
 

告诉我,如果它的工作原理。

标签:重写使用一些网页



分享:

  • 微信
  • QQ好友
  • QQ空间
  • 新浪微博


热门推荐

阿帕奇的.htaccess VS httpd的 - 它真的重要吗?(Apache .htaccess vs httpd - does it really matter)

problem i know this question has been asked many times an ...

使用的.htaccess来限制访问文件下载(Use .htaccess to limit access to file downloads)

problem i have downloads for static files like product.ex ...

重定向使用基于引用的htaccess(Redirect using htaccess based on referrer)

problem we only want users from a specific we ...

自适应图像CakePHP的htaccess的(Adaptive images CakePHP htaccess)

problem i'm trying to get matt wilcox adaptiv ...

HTML解析不作为PHP的WAMP(html not parsing as php in wamp)

problem i amusing this snippet in my .htaccess file to pa ...

htaccess的 - 如何设置SSL在某些页面(脚本需要的修改)(.htaccess - How to set SSL on certain pages (Script need's modifying))

problem i have ssl enabled on whole website, ...

htaccess的清洁网址不是由Apache的阅读?(htaccess for clean urls not being read by apache)

problem i'm getting kinda crazy over here bec ...

使用的.htaccess强制HTTP(Forcing http using .htaccess)

problem this is the script i have right now, how do i hav ...

电子名片的.vcf文件下载浏览器支持 - GoDaddy的(vCard .vcf file download browser support - godaddy)

problem i have a download vcard (.vcf) link on a site. it ...

添加一个标题给每个使用的.htaccess的请求(Add a header to each request using .htaccess)

problem i want to add a custom header to a phpbb installa ...

在.htaccess条件的php_flag声明(Conditional php_flag statements in .htaccess)

problem is there a way to conditionally execute php_flag ...

的.htaccess - 改图标(.htaccess - redirect favicon)

problem how do i redirect all requests for fa ...

我如何阻止请求从中国到我的应用程序?(How Can I Block Requests from China to My App)

problem i have an api that is somewhat popular (10,000+ r ...

htaccess的缓存不工作(htaccess caching not working)

problem i inputted the following into my htac ...

设置Apache的错误的时候了Silex的引导:无法检查htaccess文件(Apache error when setting up Silex Bootstrap: unable to check htaccess file)

problem i'm trying to set up a website using silex bootst ...

codeigniter子域路由(Codeigniter subdomain routing)

problem i'm trying to setup a blog script on a website ru ...

强制一个特定的页面使用HTTPS与angularjs(Forcing a specific page to use HTTPS with angularjs)

problem in our application we have a payment page that we ...

HTTP基本认证排除单个文件(HTTP Basic Auth Exclude Single File)

problem part of my .htaccess file looks like this- authu ...

mod_rewrite的的RewriteCond - 是必要的只是域部分NC标志?而一些更(mod_rewrite RewriteCond - is NC flag necessary for just domain part And some more)

problem i have seen many times in htaccess th ...

的.htaccess重定向到404页的重写规则(.htaccess redirect to 404 page RewriteRule)

problem is there a way to enter a rewriterule in the htac ...