I am helping a friend switch from Godaddy quick shopping cart to magento. Unfortunately the Godaddy cart automatically creates product and catalog URLS. Using caps, dashes and underscores. I can dupe the link text but magento only allows dashes and no caps, I'd rather not use caps or underscores anyway. So from what I understand I can fix this issue with htaccess 301 rewrites? Can anyone please provide examples on how to handle either or both issues, with either a link to an explanation of how this works or if you can explain it yourself that's great. I'm hoping there is some magic that can handle all the links and not have to create individual rewrites for every page, this site has over 500 products with hundred of external links so we want have to preserve the SEO rating and allow those unruly external links to work after the switch. Same domain so thats not an issue. Magento will be hosted on a VPS, version CE 1.9.2.0
Hopefully this is in the correct area for thid type of question
Dani AI
— short practical plan and two safe ways to handle this (server-level = best for a VPS; .htaccess = fallback).
You should use server-side 301 (permanent) redirects so every old URL points to the new canonical Magento URL — that preserves link signals during a move and is Google’s recommended approach. (developers.google.com)
Server-level (recommended on your VPS)
- Write a small normalization map/program (or use an Apache RewriteMap) that: 1) replaces underscores with hyphens, 2) lowercases the path, and 3) handles any .html or suffix differences you need. Call that map from your vhost so every request is passed to the normalizer and, if different, redirected with a single 301. This avoids per-URL rules and long redirect chains. Apache supports int:tolower and prg/text RewriteMap types for this. (httpd.apache.org)
Example (vhost/httpd.conf; sketch):
RewriteEngine On
# server config only
RewriteMap norm prg:/usr/local/bin/normalize-url.pl
# skip real files/dirs
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule .* - [L]
# normalize: pass REQUEST_URI to the program and redirect if it returns a different path
RewriteCond %{REQUEST_URI} (.*)
RewriteRule ^ ${norm:%1} [R=301,L] (Implement normalize-url.pl to output the canonical path or the original if unchanged.) (httpd.apache.org)
.htaccess fallback (if you cannot edit vhost)
- On Apache 2.4+ you can lowercase with an expression and handle underscores with a small looping rule. Skip existing files (images, CSS) first and add DPI to avoid PATH_INFO duplication. This method may produce more internal iterations, so test carefully.
Example (.htaccess):
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule .* - [L]
# replace underscores with hyphens, loop until none remain
RewriteRule ^([^_]*)_([^_]*)$ $1-$2 [N,DPI]
# lowercase (Apache 2.4+)
RewriteCond expr "tolower(%{REQUEST_URI}) =~ /(.*)/"
RewriteRule [A-Z] %1 [R=301,L] See examples and cautions about the N/DPI flags and using tolower() in expressions. (stackoverflow.com)
Final notes
- Always test with curl -I and a staging vhost, watch for redirect chains, and exclude static assets from normalization. Apache’s default query-string behavior and QSA rules are important if you append or preserve query strings. Keep redirects in place long enough and monitor via Search Console. ()
If needed, share one or two sample old URLs and the exact Magento target format and a short snippet of your vhost/.htaccess and I’ll sketch the minimal normalizer script or tighten the rules so you get one canonical 301 per old URL.
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.