0

my link is like this :

http://website.com/test1/test2/public/books/detail/page_id/number/page/2

I want to remove page and 2 and convert it to :

http://website.com/test1/test2/public/books/detail/page_id/number

I can define last part of URL with :

$uri = Zend_Controller_Front::getInstance()->getRequest()->getRequestUri();
$part = basename($uri);

or define another part like this :

$parts = Explode('/', $uri);
    $id2 = $parts[count($parts) - 2];
    $id1 = $parts[count($parts) - 1];

but I have problems to remove that

2 Answers 2

2
$uri = $this->serverUrl(true);    
$parts = Explode('/page/', $uri);

the $parts[0] will be the good link you want

Sign up to request clarification or add additional context in comments.

Comments

0

I think, for your case, this should be in your controller:

$url = Zend_Controller_Front::getInstance()->getBaseUrl() .
"books/detail/page_id/" . $this->getRequest()->getParam('page_id');

PS: Syntax will be different if you are in a view script, in which case you should create a view helper anyway or you can do it in controller and assign to view.

Comments

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.