VOOZH about

URL: https://deepwiki.com/MahoCommerce/maho/8.7-url-rewrites-and-seo

⇱ URL Rewrites and SEO | MahoCommerce/maho | DeepWiki


Loading...
Last indexed: 15 May 2026 (ea8ab8)
Menu

URL Rewrites and SEO

This page documents the URL rewrite system, SEO configuration, and metadata management in Maho. It explains how internal system paths are transformed into search-engine-friendly URLs, the indexing logic behind these transformations, and how SEO metadata is managed across products, categories, and integrated modules.

Purpose and Scope

The URL rewrite system is a core component of Maho's catalog management. It serves several critical functions:

  • SEO Optimization: Transforms internal routes (e.g., catalog/product/view/id/123) into keyword-rich URLs (e.g., blue-widget.html).
  • Link Integrity: Maintains permanent 301 redirects when product or category URL keys change, preventing 404 errors for indexed external links. This is managed primarily by the admin URL rewrite controller saving mechanisms. app/code/core/Mage/Adminhtml/controllers/UrlrewriteController.php110-180
  • Store Scoping: Supports multiple store views by maintaining different URL structures per store environment, allowing different URL keys per store. app/code/core/Mage/Core/Model/Url.php264-268
  • Canonicalization and Trailing Slashes: Supports canonical URL tags and global trailing slash policies to avoid duplicate content penalties. These policies are configurable and enforced primarily via the core URL helper. app/code/core/Mage/Core/Helper/Url.php214-238

Maho integrates these features seamlessly into the front controller’s request dispatch and URL generation subsystems.


URL Rewrite System Architecture

The rewrite system decouples internal module/controller/action routes from browser-visible URLs by employing a lookup table (core_url_rewrite) synchronized by indexers. Friendly URLs rewrite incoming requests to internal paths transparently.

Core Components and Data Flow

  • Core URL Rewrite Table: Contains mappings of request_path (SEO-friendly URLs) to target_path (internal routes).
  • Mage_Core_Model_Url: Responsible for URL generation including resolving rewrites and assembling full URLs.
  • Mage_Core_Helper_Url: Provides utilities for manipulating URLs such as adding trailing slashes, adding/removing route/query parameters, and encoding URLs.
  • Mage_Core_Controller_Request_Http: Stores request parameters that help resolve requests and generate URLs.
  • Mage_Adminhtml_UrlrewriteController: Provides Admin UI and logic for managing URL rewrites, including saving, deleting, and validating rewrite rules.

URL Generation and Resolution Logic Diagram


This diagram shows how user-friendly URLs and internal system URLs are linked through the URL rewrite table, and the classes managing these flows.

Sources:
app/code/core/Mage/Core/Model/Url.php160-179
app/code/core/Mage/Core/Controller/Request/Http.php227-255
app/code/core/Mage/Core/Helper/Url.php214-238
app/code/core/Mage/Adminhtml/controllers/UrlrewriteController.php110-180


Database and Configuration Structure

The core_url_rewrite table stores URL rewrite rules with the following critical columns:

ComponentDescriptionCode Reference
store_idStore view scope for this rewrite ruleapp/code/core/Mage/Core/Model/Url.php264-268
request_pathThe SEO-friendly URL path (browser-visible URL)app/code/core/Mage/Core/Model/Url.php44-60
target_pathThe internal system path (module/controller/action and params)app/code/core/Mage/Core/Model/Url.php44-60
id_pathUnique identifier grouping rewritesapp/code/core/Mage/Adminhtml/controllers/UrlrewriteController.php127-171
optionsRedirect options, e.g., 'R' for redirectapp/code/core/Mage/Adminhtml/controllers/UrlrewriteController.php153-167
is_systemFlag indicating system-generated vs. custom rewriteapp/code/core/Mage/Adminhtml/Block/Urlrewrite/Grid.php62-70
descriptionOptional descriptive text for admin interfaceapp/code/core/Mage/Adminhtml/controllers/UrlrewriteController.php130-131

Trailing Slash Configuration

Trailing slash behavior can be configured globally through admin configuration, influencing URL canonicalization and redirection policies:

  • Options include Redirect to URL with trailing slash, without trailing slash, or do nothing.
  • Implemented using Mage_Adminhtml_Model_System_Config_Source_Catalog_Trailingslash.
  • URL helper enforces trailing slash modifications during runtime URL generation.

Sources:
app/code/core/Mage/Core/Model/Url.php44-60
app/code/core/Mage/Adminhtml/controllers/UrlrewriteController.php110-180
app/code/core/Mage/Adminhtml/Block/Urlrewrite/Grid.php62-70
app/code/core/Mage/Adminhtml/Model/System/Config/Source/Catalog/Trailingslash.php13-27


URL Generation Logic

Mage_Core_Model_Url builds URLs for frontend and admin routing. It assembles components such as schema, host, port, base path, route names, controller, actions, route params, query strings, and fragments.

URL Structure

The canonical structure of URLs generated by Mage_Core_Model_Url is:

https://user:password@host:port/base_path/[base_script][storeview_path]route_name/controller_name/action_name/param1/value1?query_param=query_value#fragment

Where the segments are:

SymbolDescription
AAuthority: user/pass, host, port
BPath including base paths, scripts, store-code path, route path
CAbsolute base URL (scheme + host + port + base_path)
DAction path: route_name/controller/action
ERoute parameters encoded in path segments
FHost URL (scheme + host + port)
GRoute path relative to base URL
HFully qualified route URL

URL Assembly Diagram


Sources:
app/code/core/Mage/Core/Model/Url.php44-60
app/code/core/Mage/Core/Helper/Url.php89-101


URL Helper Utilities

Mage_Core_Helper_Url provides runtime URL manipulation methods critical for SEO and correct URL processing during page rendering and redirects.

Key Methods

Method NamePurposeCode Reference
addTrailingSlash()Adds a trailing slash to URLs without extensions for uniformity in SEO URLs.app/code/core/Mage/Core/Helper/Url.php214-228
removeTrailingSlash()Removes trailing slashes for URLs to conform with global trailing slash policy.app/code/core/Mage/Core/Helper/Url.php230-238
setRouteParams()Adds, updates, or removes Varien-style URL parameters encoded in path segments.app/code/core/Mage/Core/Helper/Url.php106-131
addRequestParam()Adds query string parameters to URLs.app/code/core/Mage/Core/Helper/Url.php157-177
getCurrentUrl()Retrieves the current full URL from the request including scheme and port.app/code/core/Mage/Core/Helper/Url.php22-35
buildUrl()Utility that reconstructs URLs from parse_url components.app/code/core/Mage/Core/Helper/Url.php89-101

These helpers are used throughout layouts, blocks, and controllers to ensure consistent URL syntax, helpful especially when redirecting or generating links dynamically.


Catalog URL Rewrites Admin Interface

The Mage_Adminhtml_UrlrewriteController handles administration of URL rewrites with key capabilities:

  • CRUD Operations on custom and system URL rewrites.
  • Product and Category Association: Auto-linking rewrites with product/category entities.
  • Rewrite Validation: Ensures uniqueness and format integrity during save attempts.
  • Redirect Management: Supports different redirect options such as permanent and temporary redirects.

The admin UI grids and forms use block classes like Mage_Adminhtml_Block_Urlrewrite_Grid for listing rewrites, showing system vs. custom flags, and mass deletion operations.

Sources:
app/code/core/Mage/Adminhtml/controllers/UrlrewriteController.php12-183
app/code/core/Mage/Adminhtml/Block/Urlrewrite/Grid.php13-111


SEO Configuration and Canonical URLs

SEO-related settings are exposed via system configuration and affect URL formatting:

  • Trailing Slash Behavior: Controlled globally via Mage_Adminhtml_Model_System_Config_Source_Catalog_Trailingslash, enabling redirects adding or removing trailing slash.
  • Canonical URL meta: The platform encourages generating canonical URLs via layout templates and helper functions, leveraging the URL generation system.
  • Store Code in URL: Store codes can be inserted as part of the base URL path, supporting multilingual or multisite SEO strategies. app/code/core/Mage/Core/Model/Url.php33-38

Blog and Integrated Module SEO Extension

Maho integrates SEO features into its native modules, such as the Blog module. This module extends URL rewriting and SEO by:

  • Defining prefix paths for blog posts and categories for hierarchical URL structure.
  • Providing default sitemap priorities and change frequencies in its system config for blog content.
  • Using observers (Maho_Blog_Model_Observer) to automate SEO-related tasks on content changes.

These extensions ensure fully integrated SEO strategies for both standard catalog content and custom module content.

Sources:
app/code/core/Maho/Blog/etc/config.xml142-162
app/code/core/Maho/Blog/Model/Observer.php1


Summary Diagram: Natural Language SEO Concepts to Code Entities in Maho



Conclusion

The URL Rewrite and SEO system in Maho tightly integrates internal routing with SEO best practices, providing flexibility and extensibility for store views, canonical URLs, and module-specific SEO needs. It combines database-backed rewrite rules, dynamic URL generation, trailing slash policies, and admin management interfaces to provide robust SEO-friendly URL support.


Sources:

  • app/code/core/Mage/Adminhtml/controllers/UrlrewriteController.php:110-180
  • app/code/core/Mage/Core/Model/Url.php:44-60,160-179,264-268
  • app/code/core/Mage/Core/Helper/Url.php:22-35,89-101,106-141,214-238
  • app/code/core/Mage/Core/Controller/Request/Http.php:227-255
  • app/code/core/Mage/Adminhtml/Block/Urlrewrite/Grid.php:13-111
  • app/code/core/Mage/Adminhtml/Model/System/Config/Source/Catalog/Trailingslash.php:13-27
  • app/code/core/Maho/Blog/etc/config.xml:142-162
  • app/code/core/Maho/Blog/Model/Observer.php:1-1