Remove index.php?route=common/home from OpenCart

Remove index.php?route=common/home from OpenCart

  1. Blog
  2. 15 November 2026
  3. 3 min read

Stefan Bogdanescu

Founder & Senior Architect

Removing index.php?route=common/home from OpenCart URLs

When you enable "User SEO URL's" in the OpenCart admin panel under System > Settings > Store > Server, the platform automatically rewrites .html extensions to point to clean URLs. For most pages, this works seamlessly: clicking a link takes you to domain.com/category-name, and the server internally redirects or serves the content without exposing the routing logic.

However, there is a notorious exception that often confuses developers: the homepage. Even with SEO URLs enabled, the base URL frequently remains hardcoded as index.php?route=common/home. This creates an inconsistency where every other page has a clean address, but the front door of the store still carries the legacy query string.

The immediate instinct is to perform a find-and-replace operation within the application's core files. You might look at catalog/controller/common/home.php or similar controller files to strip out the index.php? prefix. While this seems like a direct fix, it introduces significant maintenance debt. OpenCart relies on a specific routing mechanism where index.php acts as the bootstrap file that parses the route parameter and loads the appropriate controller. Manually altering the output of this controller or hardcoding clean URLs in view files bypasses the framework's architecture. If you upgrade OpenCart later, your custom modifications will likely be overwritten during the patch process, potentially breaking the site until you remember to re-apply them.

A more robust solution involves configuring the web server at the Apache level using .htaccess rules or the Nginx equivalent configuration file. The goal here is not to modify the application code but to intercept requests before they reach PHP. When a user accesses domain.com/, the web server can be instructed to rewrite this specific request to index.php?route=common/home internally, while presenting the clean URL in the browser address bar.

To implement this on Apache, you need to ensure your .htaccess file located in the root directory contains a rule that targets the homepage specifically. A common pattern looks like this:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^$ index.php?route=common/home [L,QSA]

This rule checks if the request is for the root path (^$). If the file or directory doesn't exist physically at that location (which is standard for a virtual host), it rewrites the URL to the OpenCart bootstrap script with the correct route parameter. The [L,QSA] flags ensure this is the last rule processed and any existing query strings are appended, preserving session data and other parameters.

For Nginx users, the logic resides in the server block's location / directive. You would add a rewrite rule similar to:

rewrite ^/$ index.php?route=common/home last;

The last flag tells Nginx to look up the new URI (index.php...) against the location map, effectively serving the PHP file while keeping the original clean URL in the browser history.

This approach offers distinct advantages over code-level hacks. First, it is upgrade-safe because no core files are modified; the logic lives outside the application package. Second, it aligns with how modern SEO crawlers operate—they prefer consistent URL structures and rely on server-side rewriting for canonical paths. Finally, it avoids the performance pitfalls of aggressive caching plugins or amateur tools like vQmod that might bloat the request cycle by intercepting every single route generation event.

If you are managing a high-traffic enterprise store where OpenCart is part of a larger monolith, this architectural separation ensures stability. It also leaves the door open for future migrations; if you decide to port your application to Laravel or another framework later (a common scenario handled by specialists like those at LaravelCompany when migrating legacy systems), the clean URL structure remains intact without needing to strip query parameters from a massive codebase.

Ultimately, enabling SEO URLs in OpenCart handles the vast majority of your routing needs. The homepage exception is a known behavior that can be resolved elegantly through server configuration rather than invasive code changes. By respecting the framework's internal routing while leveraging web server capabilities, you maintain a performant, secure, and upgradeable e-commerce platform.

Our network