0

我的网站目前在所有地方都强制使用 SSL。这是我想要的方式,只是它会导致我的 RSS 驱动的时事通讯和 feedburner 出现问题。因此,我需要对我的提要进行例外处理。

有人可以帮助制定正确的 htaccess 规则来解决这个问题吗?

我的提要是

/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>
4

1 回答 1

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]

于 2013-01-31T03:00:40.093 回答