【问题标题】:Not working seo url from old http to https for product name and canonical urls are still on http instead of https无法使用从旧 http 到 https 的产品名称和规范 url 的 seo url 仍然在 http 而不是 https
【发布时间】:2014-12-17 23:45:15
【问题描述】:

我在将 Opencart 中的 seo 友好 URL 从旧 http 应用到新 https 时遇到问题。

之前我们曾经有像 domain.com/productname 这样好的 seo url,但上个月我们为我们的网站购买了 ssl 证书,现在所有 url 都在其 https 版本上,所以这些产品页面已经改变了它的格式,例如从 @ 987654321@ 如果你点击链接,它现在就像 opencart 中的https://www.domain.com/index.php?route=productname 一样混乱。

我只是想消除这个 index.php?route= url 参数,以便所有链接都变成 domain.com/productname。我也尝试过 GWT 来获取它而不是重定向 URL。我还检查了标题状态是否为 200。

规范网址仍然在 http 而不是 https,并且一些产品链接仍然指向 http 而不是 https强>。

到目前为止,我对关于我们的页面没有任何问题,请联系我们,他们工作正常。

下面是我的 .htaccess:

RewriteEngine On
RewriteBase /
#RewriteRule ^sitemap.xml$ index.php?route=feed/google_sitemap [L]
#RewriteRule ^googlebase.xml$ index.php?route=feed/google_base [L]
RewriteRule ^download/(.*) /index.php?route=error/not_found [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !.*\.(ico|gif|jpg|jpeg|png|js|css)
RewriteRule ^([^?]*) index.php?_route_=$1 [L,QSA] 

#This setting force logo url to it's home page
RewriteCond %{QUERY_STRING} ^route=common/home$
RewriteRule ^index\.php$ https://www.domain.com/? [R=301,L]

#This setting force http to https version
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://www.domain.com/$1 [R=301,L]

【问题讨论】:

    标签: apache .htaccess mod-rewrite redirect seo


    【解决方案1】:

    您需要在路由规则之前保留重定向规则:

    RewriteEngine On
    RewriteBase /
    
    #This setting force logo url to it's home page
    RewriteCond %{QUERY_STRING} ^route=common/home$
    RewriteRule ^index\.php$ https://www.domain.com/? [R=301,L,NE,NC]
    
    #This setting force http to https version
    RewriteCond %{SERVER_PORT} 80
    RewriteRule ^(.*)$ https://www.domain.com/$1 [R=301,L,NE]
    
    #RewriteRule ^sitemap.xml$ index.php?route=feed/google_sitemap [L]
    #RewriteRule ^googlebase.xml$ index.php?route=feed/google_base [L]
    RewriteRule ^download/(.*) /index.php?route=error/not_found [L]
    
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_URI} !.*\.(ico|gif|jpg|jpeg|png|js|css)
    RewriteRule ^([^?]*) index.php?_route_=$1 [L,QSA]
    

    还要确保在新浏览器中对此进行测试以避免旧浏览器缓存。

    【讨论】:

    • 是的,它的工作原理,但是有些 url 看起来很不寻常,比如有些 url 指向 https,有些指向 http。规范 url 仍然是 http 而不是 https。你以前遇到过这种问题吗?我检查了标题状态及其返回 200 并且也在谷歌网站管理员上做了。我的网站的 https 和 http 版本可能有一些重复的问题。
    • force http to https 规则应该强制 https 到每个 URL。
    • 所以最终他们都会在一个月左右后从http转到https?我想我会等待 Google 将这些页面编入索引并缓存在 https 版本中吧?
    • 是的,没错,最终旧的缓存页面将被新的页面替换。
    【解决方案2】:

    另一种解决方案是让您网站的 conf 中的 ssl 部分也允许覆盖

    cd /etc/apache2/sites-available

    nano yourdomain.com.conf

    添加以下代码

        <Directory "/var/www/html/yourdomain.com/public_html">
           AllowOverride All
           Require all granted
       </Directory>
    

    里面

    <VirtualHost *:443>
    .....
    
    </VirtualHost>
    

    【讨论】:

      猜你喜欢
      • 2011-04-28
      • 2017-04-20
      • 2019-02-27
      • 1970-01-01
      • 2016-01-19
      • 1970-01-01
      • 1970-01-01
      • 2013-02-28
      • 2015-04-21
      相关资源
      最近更新 更多