3

I am using magento 1.7 and I have already live site running in zencart. my zencart site's product url in Mixed case like http://wwww.example.com/Silver-Bracelet when i save product in magento with this product url key Silver-Bracelet then its auto convert into small case.

my live site url is

http://www.example.com/Silver-Badge 

and on test server magento url is

http://test.example.com/silver-badge 

when in click this url then product is open but when i type url as

http://test.example.com/Silver-Badge 

then i got page not found thats why i am search to make mixed case urls in magento so please can any body please tell me how to change this url key in to mixed case

3 Answers 3

3

I got solution for following code and it works. i know this is hack type but it solves my motive i place this code in index.php. because i am unable to put RewriteMap in httpd.conf

$loadurl = $_SERVER['REQUEST_URI'];
$match   = array();

$port = $_SERVER['SERVER_PORT'] == 80 ? 'http://' : 'https://';

if( preg_match('/([A-Z])/',$loadurl) && $_SERVER['REQUEST_METHOD'] == 'GET'){
  header("HTTP/1.1 301 Moved Permanently"); 
  $url = $port.$_SERVER['SERVER_NAME'].'/'.strtolower( strtoupper( trim( $_SERVER['REQUEST_URI'] ,'/') ));
  header('location:'.$url);
  exit;
}
2

Rather than change Magento, can't you change your URLs?

Is there any reason you can't just have it in lower case? Simply adding this to your .htaccess would preserve any indexed URLs.

RewriteEngine On
RewriteMap  lc int:tolower
RewriteCond %{REQUEST_URI} [A-Z]
RewriteRule (.*) ${lc:$1} [R=301,L]

URLs in lower case are move advantageous for a number of reasons ...

  • URL consistency
  • Easier to type a URL by hand without scope for error
  • Looks cleaner

But that's just my £0.02

3
  • As Sonassi says... Why must the new system work like the old system? Mixed case URLs is so 1996 and given all the other issues you're going to have making Magento work, this is one of those fights that ends up in a Pyrrhic victory for all. Much effort expended for little gain. Commented Feb 25, 2013 at 15:55
  • 1
    We went down the road of changing Magento to allow for mixed case urls. We will never attempt that again. It was a total nightmare. Magento converts to lowercase in so many different places that it really makes sense to just do the permanent redirects and change all the urls when you migrate. We have not found any cases where this results in a large positioning drop that is not easily recoverable.
    – mattmac
    Commented Feb 25, 2013 at 17:15
  • RewriteMap lc int:tolower is not working on my server when i add this line into htaccess then i got internal server error
    – user482
    Commented Feb 26, 2013 at 5:00
2

Definitely just setup 301 redirects for all these urls to lower case versions as Magento wants you to do. Matt Cutts just confirmed that 301 redirects do not hurt page rank at all http://searchengineland.com/google-pagerank-dilution-through-a-301-redirect-is-a-myth-149656

3
  • i thought also as you think but on my server my live site url is http://www.example.com/Silver-Badge and on test server magento url is http://test.example.com/silver-badge when in click this url then product is open but when i type url as http://test.example.com/Silver-Badge then i got page not found
    – user482
    Commented Feb 26, 2013 at 5:02
  • add the redirect rule to your VirtualHost block in apache as sonassi mentions in his answer. That will do the actual redirecting for you. Magento doesn't do it by default. Magento does convert any text you enter as a url key into a product detail page in the admin to lowercase.
    – mattmac
    Commented Feb 27, 2013 at 4:46
  • how i can change httpd or VirtualHost block on hosting server from cpanel
    – user482
    Commented Feb 27, 2013 at 9:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.