I doing a filter system with pagination and i am in a trouble trying to redirect with Javascript depending on the current URL.
I can have this types of URLs where the last number is a filter:
http://localhost/posts/yourPosts/1
http://localhost/posts/subscriptions/3
And inside each type, page 2 will be shown in this way:
http://localhost/posts/yourPosts/1/page:2?url=posts%2FyourPosts
http://localhost/posts/subscriptions/3/page:2?url=posts%2FSubscriptions
I am currently using:
window.location.href = currentURL + '/' + encodeURI($(this).val());
Where $(this).val is the number of the filter to use.
The problem is that when i am in this URLs it works well:
http://localhost/posts/yourPosts/
http://localhost/posts/subscriptions/
But when i am in the 2nd page and i want to show the filter number 3 (lets say, cars instead of animals), it doesn't. It show this:
http://localhost/posts/subscriptions/2/page:2?url=posts%2FyourPosts/3
Instead of this:
http://localhost/posts/subscriptions/3
Is there any simple way to deal with URLs to solve this kind of problem?
I can not either use an absolute path because the URLs are not all the same. So... is there any way to change the last PATH of a URL?