OpenCart 3. https and SEO URL conflict - solved
It took time to me to solve that problem, fortunately I am not greedy and I share this knowlege.
To enable HTTPS without affecting SEO URL and vice versa, and also remove "route=common/home" from home page in OpenCart websites, you need to do the following:
1. Check if mod_rewrite engine enabled on your server (Click to know how).
2. Write proper # enable HTTPS module, set it below your # SEO URL settings in your .htaccess file. Something like this:
# SEO URL Settings
RewriteEngine On
# If your opencart installation does not run on the main web folder make sure you folder it does run in ie. / becomes /shop/
RewriteBase /
# Remove route=common/home from home page
RewriteCond %{QUERY_STRING} ^route=common/home$
RewriteCond %{REQUEST_METHOD} !^POST$
RewriteRule ^index\.php$ http://%{HTTP_HOST}? [R=301,L]
# Set SEO URLs
RewriteRule ^sitemap.xml$ index.php?route=extension/feed/google_sitemap [L]
RewriteRule ^googlebase.xml$ index.php?route=extension/feed/google_base [L]
RewriteRule ^system/storage/(.*) 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]
# enable HTTPS
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTPS} =off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [QSA,L]
</IfModule>
3. Make changes in two config.php files: at your home directory (usually it is public.html) and admin directory.
Changes in config file at public.html directory:
// HTTP
define('HTTP_SERVER', 'https://yourdomain.name/');
// HTTPS
define('HTTPS_SERVER', 'https://yourdomain.name/');
So, you must just add 's' to both servers.
Changes in config file at admin directory:
// HTTP
define('HTTP_SERVER', 'http://yourdomaine.name/admin/');
define('HTTP_CATALOG', 'http://yourdomaine.name/');
// HTTPS
define('HTTPS_SERVER', 'https://yourdomaine.name/admin/');
define('HTTPS_CATALOG', 'https://yourdomaine.name/');
It was not necessary to add 's' to define http server there, because there are not SEO redirections in admin zone.
To finish in full with all non SEO URLs (in footer) you should do one more thing: Go to catalog>controller>startup>seo_url.php
Goto line no 78, after the following string:
foreach ($data as $key => $value) {
add the following code:
$q=$this->db->query("SELECT keyword FROM " . DB_PREFIX . "seo_url WHERE query='$value'");
if($q->row) { $url .= '/' . $q->row['keyword']; }
Now you can go to admin panel of Open Cart: Design>SEO URL and add new seo url.
For contact put the following:
query=information/contact
keyword=contact-us or anything you wish.
Repeat for other URL's in the footer.
That is it.
I use C-Panel with LiteSpeed Server at FOZZY internet hosting.