dongwupu5991 2017-03-29 09:57
浏览 37

有关Canonical Tag和.htaccess的设置

I have this problem for quite a while now and already read lots about it, but I still keep getting in trouble with my redirects or potential duplicate Content, being triggered by my settings in the .htaccess together with my canonical tag in order to clean up with trailing slashes and different variants of my page.

Currently different tools show that my pages, e.g. /potatoe is also found under /potatoe/. Moreover I have other pages that trouble with double-redirects, because I seemingly redirect with a permanent 301, which does not take into account the canonical tag on the page. So, e.g. /potatoe/ (with "/") is set as a canonical tag and the source code shows (without even regarding the canonical tag):

<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>301 Moved Permanently</title>
</head><body>
<h1>Moved Permanently</h1>
<p>The document has moved <a href="https://example.com/potatoe/">here</a>.</p>
<hr>
<address>Apache Server at example.com Port 443</address>
</body></html>

My .htaccess is as follows:

ErrorDocument 404 /error404.php

RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} !^$
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteCond %{HTTPS}s ^on(s)|
RewriteRule ^ http%1://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L]

AddDefaultCharset utf-8

order allow,deny
allow from all
deny from 123.249.24.233

RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\/index\.php\ HTTP/
RewriteRule ^index\.php$ https://example.com/ [R=301,L]

RewriteRule ^Index\.php$ /index.php [R=301,L]

RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /index\.(html?|php)\ HTTP/
RewriteRule ^index\.(html?|php)$ https://example.com/ [R=301,L]
RewriteRule ^index\$ https://example.com/ [R=301,L]

I am thankful for any help/tips!

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 IAR程序莫名变量多重定义
    • ¥15 (标签-UDP|关键词-client)
    • ¥15 关于库卡officelite无法与虚拟机通讯的问题
    • ¥15 qgcomp混合物线性模型分析的代码出现错误:Model aliasing occurred
    • ¥100 已有python代码,要求做成可执行程序,程序设计内容不多
    • ¥15 目标检测项目无法读取视频
    • ¥15 GEO datasets中基因芯片数据仅仅提供了normalized signal如何进行差异分析
    • ¥100 求采集电商背景音乐的方法
    • ¥15 数学建模竞赛求指导帮助
    • ¥15 STM32控制MAX7219问题求解答