Jump to content

How to get URI without query parameters?


Nikita_kharkov

Recommended Posts

Hello! I didn't find any inbox parameter which give me only URI except "$come_from", but it contains GET parameters. Few examples:

 

I need:

 http://myhost.com/some-category/some-subcategory.

From $_SERVER['REQUEST_URI'] I could get it only if it don't content some query parameters (URI like 

 http://myhost.com/some-category/some-subcategory?new=true

 or  

http://myhost.com/some-category/some-subcategory#/some-Filter)

Can help somebody? I don't want spend time for writing this functions and want to use inbox vars. 

Edited by Nikita_kharkov (see edit history)
Link to comment
Share on other sites

I made my own little solution and add it to FrontController as $page_uri_without_params variable. This issue arose when I have to add canonical link for SEO. I had to add link without any parameters. I hope this solution help to somebody.

 

$page_uri_without_params = substr($this->context->shop->getBaseURL(), 0, -1). // remove slash at the end
       preg_replace('@(/?\?.*)|(/#.*)|(/$)@', '', $_SERVER['REQUEST_URI']); // remove PS query and standart query 
Edited by Nikita_kharkov (see edit history)
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...