Vue Storefront is now Alokai! Learn More
URL Routing

URL Routing

Alokai Storefront uses file-based routing with configurable URL patterns that differ between SAP Commerce Cloud and other integrations.

Default URL Patterns

PageSAPCCOther Integrations
Category/c/[[...slugs]]/category/[[...slugs]]
Product/p/[slug]/[id]/product/[slug]/[id]

SAP Commerce Cloud uses short /c and /p prefixes because these are the native SAP CC URL format. SAP CC generates URLs like /Collections/Streetwear/c/streetwear where the category slug follows a /c/ marker. Alokai matches these URLs with rewrites that strip the breadcrumb prefix, leaving /c/streetwear.

SAPCC customers typically migrate existing stores to Alokai — their /c/ and /p/ URLs already have established Google rankings. Default routing preserves these URLs so you don't lose search traffic.

How Routing Is Configured

Routing in an Alokai Next.js storefront is built from four layers:

  1. File-based routing — Next.js pages like app/[locale]/(default)/c/[[...slugs]]/page.tsx define the URL structure.
  2. Route configconfig/routes.ts defines pathname patterns used by components to build links.
  3. Navigation configconfig/navigation.ts exports pathnames for next-intl i18n routing.
  4. Native URL rewritesconfig/rewrites.config.mjs handles SAP CC breadcrumb-prefixed URLs (e.g., /Collections/Streetwear/c/streetwear/c/streetwear).

Page components are decoupled from URL patterns — they re-export from sf-modules:

app/[locale
export { default, generateMetadata } from '@/sf-modules/category';

This decoupling means you can change URL paths without modifying any page logic.

Why Consider SEO-Friendly URLs

There are cases where /category and /product prefixes might be preferable:

  • Descriptive URLs help users and search engines — Google recommends using descriptive words in URL paths rather than abbreviated codes.
  • User trust — users can understand page content from the URL before clicking.
  • Consistency — matches other Alokai integrations and common e-commerce conventions.

Changing URLs on a live store affects SEO. Only migrate if the benefits outweigh the risk and effort. Existing /c/ and /p/ URLs may already rank well in search results.

Rewrites vs Redirects

Before migrating, it's important to understand the two URL mechanisms already in play:

Rewrites (already in place) internally route SAP CC breadcrumb-prefixed URLs to the correct page handler. The browser URL doesn't change. For example, /Collections/Streetwear/c/streetwear is internally rewritten to /c/streetwear. After migration, you'll update the rewrite destinations but keep the same sources. See Next.js Rewrites docs for full configuration options.

Redirects (needed for migration) send an HTTP response telling browsers and search engines that a URL has permanently moved. Use 301 (Moved Permanently) — this is Google's standard recommendation for URL migrations and tells search engines to transfer ranking signals to the new URL. See Next.js Redirects docs and Google's redirects guide.

Migrating to SEO-Friendly URLs

1

Rename route directories

Rename the page directories — the page files inside don't change since they just re-export from sf-modules.

mv app/[locale]/(default)/c  app/[locale]/(default)/category
mv app/[locale]/(default)/p  app/[locale]/(default)/product

2

Update route config

config/routes.ts
export const routes = {
  categoryPage: ({ slugs }: CategoryPageParams = {}) => ({
    params: { slugs: slugs ?? [] },
    pathname: '/c/[[...slugs]]' as const,     pathname: '/category/[[...slugs]]' as const,   }),
  productPage: ({ id, slug }: ProductPageParams) => ({
    params: { id, slug },
    pathname: '/p/[slug]/[id]' as const,     pathname: '/product/[slug]/[id]' as const,   }),
};

3

Update navigation config

In config/navigation.ts, replace the /c and /p pathnames:

config/navigation.ts
export const pathnames = {
  '/c': '/c',   '/c/[[...slugs]]': '/c/[[...slugs]]',   '/category': '/category',   '/category/[[...slugs]]': '/category/[[...slugs]]',   // ...
  '/p/[slug]/[id]': '/p/[slug]/[id]',   '/product/[slug]/[id]': '/product/[slug]/[id]', } satisfies Pathnames<typeof locales>;

4

Update rewrites

In config/rewrites.config.mjs, change the rewrite destinations to the new paths. Keep the sources unchanged — they still need to match SAP CC native URLs:

config/rewrites.config.mjs
export default async function rewrites() {
  return {
    beforeFiles: [
      { destination: '/:locale/c/:slugs*', source: '/:locale/:prefix+/c/:slugs*' },       { destination: '/:locale/p/:code/:code', source: '/:locale/:prefix+/p/:code' },       { destination: '/:locale/category/:slugs*', source: '/:locale/:prefix+/c/:slugs*' },       { destination: '/:locale/product/:code/:code', source: '/:locale/:prefix+/p/:code' },     ],
  };
}

5

Set up 301 redirects

Add permanent redirects from the old paths to the new ones. This tells search engines to transfer ranking signals:

next.config.mjs
async redirects() {
  return [
    { source: '/:locale/c/:slugs*', destination: '/:locale/category/:slugs*', permanent: true },
    { source: '/:locale/p/:slug/:id', destination: '/:locale/product/:slug/:id', permanent: true },
  ];
},

See the Next.js Redirects docs for full configuration options.

Further Reading