我需要重新直接3页从HTTP到HTTPS网站。 我需要的所有其他网页保持HTTP。
我一直在淘这个网站,寻找一个可行的解决方案在网络两天。 什么都没有提供一个完整的解决方案。
需要HTTPS两页的根目录,一个是在子文件夹。 我一直在摆弄既.htaccess文件,但我希望一切都可以在根文件来完成。
我是新来的正则表达式和的.htaccess指令,所以我道歉,如果该解决方案是显而易见的一些你。
这里的根.htaccess文件到目前为止,我已经把。 我打开你的代码的任何部分反馈。 谢谢你的帮助!
RewriteEngine On
# redirects non-www page requests to www version
RewriteCond %{HTTP_HOST} ^mywebsite.com
RewriteRule (.*) http://www.mywebsite.com/$1 [R=301,L]
# PERTINENT CODE BLOCK BELOW
# page (order-form) has to be on https **[SEEMS TO WORK]**
RewriteCond %{HTTPS} !on
RewriteCond %{REQUEST_URI} ^/order-form/$ [NC]
RewriteRule ^(.*)$ https://www.mywebsite.com/$1 [L,R=301]
# page (employment-application) has to be on https **[SEEMS TO WORK]**
RewriteCond %{HTTPS} !on
RewriteCond %{REQUEST_URI} ^/employment-application/$ [NC]
RewriteRule ^(.*)$ https://www.mywebsite.com/$1 [L,R=301]
# page (about/contact-us) has to be on https **[NOT WORKING]**
RewriteCond %{HTTPS} !on
RewriteCond %{REQUEST_URI} ^/about/contact-us/$ [NC]
RewriteRule ^(.*)$ https://www.mywebsite.com/$1 [L,R=301]
# All other pages have to be on http **[NOT WORKING]**
RewriteCond %{HTTPS} on
RewriteCond %{REQUEST_URI} !^/order-form/$ [NC]
RewriteCond %{REQUEST_URI} !^/employment-application/$ [NC]
RewriteCond %{REQUEST_URI} !^/about/contact-us/$ [NC]
RewriteRule ^(.*)$ http://www.mywebsite.com/$1 [L,R=301]
# END - PERTINENT CODE BLOCK
# remove .php file extensions
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^([^/]+)/$ $1.php
# adds a trailing slash
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !(\.[a-zA-Z0-9]{1,5}|/)$
RewriteRule (.*)$ /$1/ [R=301,L]
# disables directory view on web pages
Options -Indexes
# cached pages will expire in 5 days
ExpiresActive On
ExpiresDefault "access plus 5 days"
# send 404 errors to home page
# info at http://httpd.apache.org/docs/current/mod/core.html#errordocument
ErrorDocument 404 /