Reputation: 51
I'm having issue in applying seo friendly URL in Opencart from old http to new https.
Before we used to have good seo url like domain.com/productname but last month we purchased ssl cert for our site, now all urls is now on its https version, so those product pages have changed its format for example from http://domain.com/productname if you click the links it now messy like https://www.domain.com/index.php?route=productname in opencart.
I just want to eliminate this index.php?route= url parameters so that all links would become domain.com/productname. I also did try GWT to fetch to see it not a redirect URL. I also did check on the header status is 200.
Canonical urls are still in http not https, and some product links are still pointing to http instead of https.
So far I don't have any issue with page like about-us contact-us they're working fine.
Here are my .htaccess below:
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]
Upvotes: 1
Views: 1347
Reputation: 121
another solution is to make the ssl part of your website's conf also allow override
cd /etc/apache2/sites-available
nano yourdomain.com.conf
add the following code
<Directory "/var/www/html/yourdomain.com/public_html">
AllowOverride All
Require all granted
</Directory>
inside
<VirtualHost *:443>
.....
</VirtualHost>
Upvotes: 0
Reputation: 786329
You need to keep redirect rules before your routing rules:
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]
Also make sure to test this in a new browser to avoid old browser caches.
Upvotes: 1