URL重写问题双http问题

时间:2014-09-07 11:45:28

标签: .htaccess mod-rewrite redirect url-rewriting http-status-code-301

我的网址存在问题谷歌已经抓取了双重http,例如

http://example.com/example.com/c-title-id.html

以及所有相互关联的页面

请任何人帮助我重定向301与.htacess

的所有网址

我的htacess代码是

RewriteEngine on

RewriteCond %{HTTP_HOST} ^www\.website\.com [NC]
RewriteRule ^(.*)$ http://website.com/$1 [L,R=301]

RewriteRule category-([0-9]+)-(.*)-([0-9]+)\.html$ category.php?cid=$1&name=$2&page=$3.php [L]
RewriteRule search-(.*)-([0-9]+)\.html$ search.php?term=$1&page=$2.php [L]
RewriteRule all-covers-([0-9]+)\.html$ all-covers.php?page=$1.php [L]
RewriteRule index-([0-9]+)\.html$ index.php?page=$1.php [L]
RewriteRule featured-covers-([0-9]+)\.html$ featured-covers.php?page=$1.php [L]
RewriteRule top-downloaded-([0-9]+)\.html$ top-downloaded.php?page=$1.php [L]
RewriteRule c-([0-9]+)(.*)\.html$ cover.php?id=$1&name=$2.php [L]
RewriteRule sitemap.xml$ sitemap.php [L]
RewriteRule sitemap1.xml$ sitemap1.php [L]
RewriteRule rss.xml$ rss.php [L]
RewriteRule ^(.*)\.html$ $1.php [L]

ErrorDocument 404 /404.html

我想自动重定向所有这些。

1 个答案:

答案 0 :(得分:1)

应该像在规则的顶部那样简单:

RewriteEngine on

RewriteCond %{HTTP_HOST} ^www\.website\.com [NC]
RewriteRule ^(.*)$ http://website.com/$1 [L,R=301]

RewriteRule example\.com/(.*)$ /$1 [R=301,L]

#... rest of your rules...