0

I'm trying to change products URL on save using:

$product->setUrlKey($url);.

It works just fine but when I't trying to reach in front the product, it's responsing to Old URL. How can I make product to respond to New Url?

  • According to magento takes all config data from cache folder you have to clear the magentodir/var/cache - including all subfolders - to be sure the new config is taken. & even browser cache – Arjun Sep 12 '16 at 8:43
3

Its showing old url then core_url_rewrite table is not updated, in this case you have to do reindexing please do reindexing and let me know its working or not

301 url redirect in .htacess for you

<IfModule mod_rewrite.c>
     redirect 301 baseurl/old_url.html  base_url/new_url.html
</IfModule> 

Above code is for .htaccess file only

  • It didn't work. I have product save with one url, and in front it shows old url. – ana.coman93 Sep 12 '16 at 8:42
  • truncate this table and then do reindexing and then let me know – Murtuza Zabuawala Sep 12 '16 at 8:44
  • Now it works! But when I reach old URL in front it gives me "Adress dosn't exist". How can I make old link redirect automatically to new one? – ana.coman93 Sep 12 '16 at 8:52
  • 1
    If My answer solve your problem then mark as accepted – Murtuza Zabuawala Sep 12 '16 at 8:57
  • 1
    Please check my updated answer for .htaccess – Murtuza Zabuawala Sep 12 '16 at 14:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.