0
我原以为这会更好地记录在某处,但无法找到有关该主题的许多信息。.htaccess:非www到www +不扩展网址+没有索引
基本上我使用htaccess的在网站上灌输3条规则我的工作:
- 重定向/重写非www到www
- 从每个网站的网页的删除扩展 - 他们是PHP文件。这意味着网站索引变成www.example.co.uk/index而不是www.example.co.uk/index.php,所以...
- 重定向/重写www.example.co.uk/指数www.example.co.uk/
这是我从各种来源编译脚本,它的工作,但谷歌似乎并不当我指向的扩展名被抓取网站在网站地图的网址,任何想法为什么?提前致谢。
Options +FollowSymlinks
RewriteEngine On
# Rewrite index.php to/
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /([^/#?\ ]+/)*index\.php?\ HTTP/
RewriteCond %{HTTP_HOST} ^(www\.example\.co\.uk) [OR]
RewriteCond www.%{HTTP_HOST} ^(www\.example\.co\.uk)
RewriteRule ^(([^/]+/)*)index\.php?$ http://%1/$1 [R=301,L]
# Rewrite example.co.uk to www.example.co.uk for canonic purposes, this rule is paired with the previous
RewriteCond %{HTTP_HOST} ^example\.co\.uk [NC]
RewriteRule ^(.*)$ http://www.example.co.uk/$1 [R=301,L]
#REMOVE .php from file extensions
# If the requested URI does not contain a period in the final path-part
RewriteCond %{REQUEST_URI} !(\.[^./]+)$
# and if it does not exist as a directory
RewriteCond %{REQUEST_fileNAME} !-d
# and if it does not exist as a file
RewriteCond %{REQUEST_fileNAME} !-f
# then add .php to get the actual filename
RewriteRule (.*) /$1.php [L]
# If client request header contains php file extension
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /([^.]+\.)+php\ HTTP
# externally redirect to extensionless URI
RewriteRule ^(.+)\.php$ http://www.example.co.uk/$1 [R=301,L]
有什么问题呢?如果您想知道Google为什么不抓取该网站,Google的抓取规则是由Google组成的 - 如果它不起作用,则不起作用。 – Rushyo 2010-09-17 13:20:48
问题是,如果我有任何明显的错误,我会阻止它被正确抓取..对不起,我应该已经做得更清楚了..就像我说的规则组合很少记录。干杯 – Storsey 2010-09-17 13:26:53