除了rss feed之外,htaccess强制ssl

时间:2013-01-31 02:42:01

标签: wordpress apache .htaccess rss

我的网站目前在任何地方强制使用SSL。这是我想要的方式,除了它导致我的RSS驱动的时事通讯和feedburner的问题。因此,我需要为我的Feed添加例外。

有人可以帮助解决正确的htaccess规则吗?

我的Feed

/feed
/shop/feed
/forum/discussions/feed.rss

这是强制SSL的条件。除了强制使用所有RSS源外,这都有效。

# Force SSL
RewriteCond %{SERVER_PORT} 80
RewriteCond %{REQUEST_URI} !^/forum [NC]
RewriteRule ^/?(.*)$ https://photoboothowners.com/$1 [R=301,QSA,L,NE]

我尝试了以下但是它似乎无法正常工作。

# Force SSL
RewriteCond %{SERVER_PORT} 80
RewriteCond %{REQUEST_URI} !^/forum [OR]
RewriteCond %{REQUEST_URI} !^/feed [OR]
RewriteCond %{REQUEST_URI} !^/shop/forum [NC]
RewriteRule ^/?(.*)$ https://photoboothowners.com/$1 [R=301,QSA,L,NE]

非常感谢您的帮助!


更新:这是我服务器根目录下的当前.htaccess文件。目前这是将http://photoboothowners.com/feed重定向到https://photoboothowners.com(注意它正在删除Feed目录)。

RewriteEngine on


# Use PHP5CGI as default
AddHandler fcgid-script .php

RewriteCond %{HTTP_HOST} ^buyaphotobooth\.net$ [OR]
RewriteCond %{HTTP_HOST} ^www\.buyaphotobooth\.net$
RewriteRule ^/?$ "https\:\/\/photoboothowners\.com\/starting\-a\-photo\-booth\-business\-build\-or\-buy" [R=301,L]

RewriteCond %{HTTP_HOST} ^photoboothforums\.com$ [OR]
RewriteCond %{HTTP_HOST} ^www\.photoboothforums\.com$
RewriteRule ^/?$ "https\:\/\/photoboothowners\.com\/forum" [R=301,L]

# Force SSL
RewriteCond %{HTTPS} !=on
RewriteCond %{REQUEST_URI} !^/forum [NC]
RewriteCond %{REQUEST_URI} !feed   [NC]
RewriteRule ^/?(.*)$ https://photoboothowners.com/$1 [R=301,QSA,L,NE]


RewriteCond %{HTTP_HOST} ^photoboothowners\.com$ [OR]
RewriteCond %{HTTP_HOST} ^www\.photoboothowners\.com$
RewriteRule ^how\-to\-use\-our\-premium\-print\-designs\-in\-breeze\-dslr\-remote\-pro\/?(.*)$ "https\:\/\/photoboothowners\.com\/how\-to\-use\-our\-photo\-booth\-template\-designs\-in\-breeze\-dslr\-remote\-pro$1" [R=301,L]

RewriteOptions inherit

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

# END WordPress

RewriteCond %{HTTP_HOST} ^.*$
RewriteRule ^shop\/photo\-booth\-layouts\-and\-samples\.html$ "https\:\/\/photoboothowners\.com\/shop" [R=301,L]

<Files 403.shtml>
order allow,deny
allow from all
</Files>

1 个答案:

答案 0 :(得分:0)

您的规则正在使用OR,因此它们显示为:

if server port is 80 and the request is not forum OR it is not feed OR it is not shop/forum

这将匹配一切。摆脱[OR]这两个匹配:

if server port is 80 and the request is not forum AND it is not feed AND it is not shop/forum

编辑:

根据您更新的问题,以下行缺少斜杠:

RewriteCond %{REQUEST_URI} !feed [NC]

应该是

RewriteCond %{REQUEST_URI} !/feed [NC]

相关问题