I currently have User SEO URL\'s
set to Yes in OpenCart Admin.
System -> Settings -> Store -> Server -> User SEO URL\'s
I came late but my solution could be useful for others (tested on Opencart 2.0.3.1):
Open your MySQL console and run this query (change YOURDATABASE with your db name):
INSERT INTO `YOURDATABASE`.`url_alias` (`url_alias_id`, `query`, `keyword`) VALUES (NULL, 'common/home', ' ');
How it works:
The trick consists in adding a WHITE SPACE (' ') for the column "keyword", if you insert an empty string ('') this workaround doesn't work and the url rewriter will return again index.php?route=common/home.
I created a VQMOD for this. Free download here: http://www.opencart.com/index.php?route=extension/extension/info&extension_id=14683
Works well.
Step 01. Enable USE SEO URL’s in your store server settings
Go to the “System” and click on “Settings”. Locate the store you want to alter and click the “Edit” link on the right. Finally click the “Server” tab and set the SEO URL’s radio to “Yes” and save your settings.
Note: The keywords will not be created for you automatically. You must also have Apache mod_rewrite turned on. Most web hosts will have this on by default. Step 3 of this tutorial will explain how to add the keywords.
Step 02. Change some content in your .htaccess file to make your homepage SEO URL Friendly
Go to your host control panel and edit your .htaccess file. Sometimes this file is hidden in order to unhide it you can click on your web host control panel file manager and tick the show hidden files option followed by the “go” button.
Once you locate the .htaccess file change the following lines:
RewriteBase /
RewriteRule ^sitemap.xml$ index.php?route=feed/google_sitemap [L]
RewriteRule ^googlebase.xml$ index.php?route=feed/google_base [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]
To:
RewriteBase /
RewriteRule ^sitemap.xml$ index.php?route=feed/google_sitemap [L]
RewriteRule ^googlebase.xml$ index.php?route=feed/google_base [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]
RewriteCond %{QUERY_STRING} ^route=common/home$
RewriteRule ^index\.php$ http://www.yourwebsite.co.uk? [R=301,L]
If you do the step above your home page will change from something like this: http://yourwebsite.com/index.php?route=common/home to this: http://yourwebsite.com
Step 03. Enter SEO Keywords for URL’s manually Finally, you need to enter SEO keywords for every page, information, product and category you want to have URL rewrite. You can find the field for the SEO Keywords under the Data tab when editing and creating items.
Once you have entered the SEO Keywords your URL’s will be working.
Once you have followed all these instructions you can begin to reap the benefits of higher rankings, increased traffic and more customers.
In file \system\library\response.php add next line at the beginning of the public function output()
if (!defined('HTTP_CATALOG')) $this->output = str_replace(array('index.php?route=common/home', '?route=common/home'), '', $this->output);
How about replacing a link in logo with <?php echo $base; ?>
. It will make a link to base domain and will remove index.php?route=common/home
.
Jay's solution doesn't work for me, after editing I get blank screen. So I made a new one:
Put the line before:
return $link;
Instead of after:
public function rewrite($link) {