【发布时间】:2013-10-16 05:51:49
【问题描述】:
我正在尝试对电子商务网站进行搜索引擎优化。该网站在 Wordpress 平台上使用 WooCommerce 插件。此外,它还有一个 authorize.net 网关,允许用户直接在现场付款。这意味着该站点需要 SSL 证书。
出于 SEO 的原因,我希望/需要网站在 HTTP 协议上运行,但支付网关页面(/cart、/my-account、/checkout 等)除外,它应该指向HTTPS 协议。
目前我有以下代码:
RewriteCond %{HTTPS} on
RewriteCond %{REQUEST_URI} !^/cart/
RewriteCond %{REQUEST_URI} !^/checkout/
RewriteRule (.*) http://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
使用此代码,我遇到了一些问题。首先是当我访问“购物车”页面时,它不会重定向到 https,但结帐页面会。
其次,当结帐页面确实加载时,它不会加载我的一些托管内容(Css、JS、img 等...)。我猜这是因为它们没有在相同的 https 协议上运行。我该如何解决?
第三,当我使用https://mydomain.com/somepage手动访问网站时,并不是301重定向到http://mydomain.com/somepage版本。
所有这些都让我相信我上面的代码没有正确编写。有人有什么想法吗? SEO 很重要,因此唯一应该显示的页面是 http:// 页面(我指定的页面除外)。 https 版本被 301 重定向到 http://
这是我的 htaccess 文件现在的样子 -
# 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 %{HTTPS} on
RewriteCond %{REQUEST_URI} !^/cart/
RewriteCond %{REQUEST_URI} !^/checkout/
RewriteRule (.*) http://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
<FilesMatch "^(wp-comments-post\.php)">
Order Allow,Deny
Deny from xx.xxx.xx.
Deny from xx.xxx.xx.
Deny from xx.xxx.xx.
Allow from all
</FilesMatch>
【问题讨论】:
标签: wordpress apache .htaccess https seo