4

I want to get the preview page url using:

Mage::helper('core/http')->getHttpReferer();

and it get's me something like:

http://localhost/index.php/customer/account/

How do I get just : customer/account/?

5

Well you use PHP native method parse_url() : http://php.net/manual/en/function.parse-url.php

var_dump(parse_url(Mage::helper('core/http')->getHttpReferer()));

It will give you the following result:

array(3) {
  ["scheme"]=>
  string(4) "http"
  ["host"]=>
  string(9) "localhost"
  ["path"]=>
  string(28) "/index.php/customer/account/"
}

If you want to remove the index.php you can then do:

str_replace("/index.php","","/index.php/customer/account/");

However, if you want to remove index.php for every page (which is I reckon you should do) you should check this post: How to remove index.php from front end URL In magento?

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.