基本上我有:
www.myfancysiteicantcodemyself.com/index.html
使用重写规则,因此它变为
www.myfancysiteicantcodemyself.com
但我真正想要的是:
* www.myfancysiteicantcodemyself.com / index.html中 - > www.myfancysiteicantcodemyself.com/some-cool-words-for-indexpage
www.myfancysiteicantcodemyself.com/anotherpageA.html - > www.myfancysiteicantcodemyself.com/some-cool-words-for-pageA *
...等
如何在不移动文件和创建301和谷歌从头开始评估我的情况下如何实现这一目标?
PS: atm我的htaccess喜欢这样:
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} !^www
RewriteRule ^(.*) http://www.example.com/$1 [L,R=301]
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /index\.(html?|php)\ HTTP/
RewriteRule ^index\.(html?|php)$ http://www.example.com/ [R=301,L]
ErrorDocument 404 /404.html
Header unset ETag
FileETag None
ExpiresActive On
ExpiresDefault "access plus 10 years"
AddHandler application/x-httpd-php .html .htm
答案 0 :(得分:0)
您需要执行301,因为Google仍会尝试转到/index.html
和/anotherpageA.html
,您需要301重定向才能告知搜索内容已移动的引擎。
因此,最简单的方法是重命名文件并使用301.否则,您将不得不进行301重定向以及内部重写。
例如:
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} !^www
RewriteRule ^(.*) http://www.example.com/$1 [L,R=301]
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /index\.(html?|php)\ HTTP/
RewriteRule ^index\.(html?|php)$ http://www.example.com/some-cool-words-for-indexpage [R=301,L]
RewriteRule ^some-cool-words-for-indexpage$ /index.html [L]
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /anotherpageA.html\ HTTP/
RewriteRule ^ http://www.example.com/some-cool-words-for-pageA [R=301,L]
RewriteRule ^some-cool-words-for-pageA$ /anotherpageA.html [L]
等...