Wordpress重定向到HTTPS,除了几个网址

时间:2018-03-16 08:17:04

标签: .htaccess

我希望我的wordpress页面被重定向到https,页面/联系人除外

我在我的.htaccess文件中有这个,但它不起作用:

<IfModule mod_rewrite.c>
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php
RewriteEngine on
RewriteCond %{HTTPS} off
RewriteCond %{THE_REQUEST} !contact/
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]


</IfModule>

由于

2 个答案:

答案 0 :(得分:0)

尝试将Request URI提供给RewriteCondition。

RewriteCond %{REQUEST_URI} !contact/

答案 1 :(得分:0)

首先,如果使用RewriteEngine onmod_rewrite应位于顶部,那么,最好在应用任何规则之前强制所有网络进入https,那么问题是当您排除时只有contact被强制进入https的请求才会阻止httpshttps://yourdomain.com,例如当您转到联系页面时,您的网站<IfModule mod_rewrite.c> RewriteEngine on RewriteCond %{HTTPS} off RewriteCond %{THE_REQUEST} !contact RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301] RewriteCond %{HTTPS} on RewriteCond %{THE_REQUEST} contact RewriteRule ^(.*)$ http://%{HTTP_HOST}%{REQUEST_URI} [L,R=301] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . index.php </IfModule> ,只有更改将在URI中,因此您的代码应如下所示:

contact

上面的代码会阻止所有https字的请求被强制转换为/contac/,因此,如果您希望将其指定为更多,则可以使用/contactcontact根据你的需要。

注意:清除浏览器缓存,然后对其进行测试。

更新如果您想要添加第二页,请按此(contact|secondpage)更改print(session.run(xx_tensor_after_xx_operation, feed_dict=feed_dict)) ,依此类推

相关问题