有关Canonical Tag和.htaccess的设置

时间:2017-03-29 09:57:03

标签: php apache .htaccess redirect mod-rewrite

我现在已经有这个问题了很长一段时间并且已经阅读了很多关于它的内容,但是我的重定向或潜在的重复内容仍然遇到问题,我的.htaccess中的设置和我的规范标签一起触发了使用尾部斜杠和我页面的不同变体进行清理。

目前,不同的工具会显示我的网页,例如在/potatoe下也可以找到/potatoe/。此外,我还有其他页面因双重重定向而出现问题,因为我看似使用永久301重定向,但没有考虑页面上的规范标记。所以,例如/potatoe/(带“/”)设置为规范标记,源代码显示(甚至没有关于规范标记):

<!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>

我的.htaccess如下:

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]

我感谢任何帮助/提示!

0 个答案:

没有答案