PrestaShop .htaccess redirects: writing rules without breaking your store

Question published Answer published 1532 views

The PrestaShop .htaccess file controls URL rewriting and redirects, and one misplaced rule can take the whole store offline, so edit it carefully and from a backup.

Shop Parameters > SEO & URLs, Set up URLs and .htaccess
SEO & URLs, generate the .htaccess from the back office instead of editing by hand.

Put custom rules in the right place. PrestaShop regenerates its own rules between two marker comments (# ~~start~~ ... # ~~end~~) whenever you toggle Friendly URLs or click "Generate .htaccess file." Anything you add inside that block gets overwritten, always place your custom redirects before the PrestaShop block.

Use the right redirect type. Use 301 for a page that has permanently moved (it passes link equity), 302 for a temporary move, and 410 for something permanently gone with no replacement.

Don't break the store. The classic mistakes: a catch-all rule that loops forever, or one that swallows the admin, API, modules and static files. Guard against both with conditions, e.g.:

# Add a default language prefix, but never loop or touch admin/api/modules/assets
RewriteCond %{REQUEST_URI} !^/(en|fr|de|es|it|pl)(/|$) [NC]
RewriteCond %{REQUEST_URI} !^/admin [NC]
RewriteCond %{REQUEST_URI} !^/api [NC]
RewriteCond %{REQUEST_URI} !^/modules/ [NC]
RewriteCond %{REQUEST_URI} !\.(css|js|jpe?g|png|gif|svg|webp|ico|woff2?)$ [NC]
RewriteRule ^(.*)$ https://yourstore.com/en/$1 [R=301,L]

Test with a 302 first, verify with curl -I -L, then switch to 301. For lots of redirects or non-technical staff, a database-driven redirect module with a UI is safer than hand-editing. See our PrestaShop troubleshooting guide for recovery if a rule does lock you out.

SEO Revolution's redirect manager is the safer database-driven option for most shop-level URL changes. It supports 301, 302 and 410 redirects, target entity selection for products/categories/CMS and other entities, custom URL targets, active flags, hit counters and last-hit dates. A 410 row has no replacement target and sends a real Gone response.

The module also handles cases that are awkward in .htaccess: exact matches, path-only matches that preserve the original query string, prefix redirects that preserve child paths, and safeguards that prevent a broad prefix from hijacking real module routes. It can also collapse 301 chains when redirects are added or updated, which keeps migration paths cleaner for crawlers.

Use .htaccess for server-wide rules that must run before PrestaShop, such as host, protocol or very early security rewrites. Use the redirect UI for content migrations, retired products, old CMS URLs and day-to-day SEO redirect management where you want reporting and safer edits.

Was this answer helpful?

Still have questions?

Can't find what you're looking for? Send us your question and we'll get back to you.

Loading...
Back to top