You can do this by "URL Rewrite Management"
Catalog->URL Rewrite Management-> Click "Add URL Rewrite" button
Then
Select "For Category" -> Select a category you want to rewrite to product page.
Then enter your product url in 4th field "Request Path".
here hoodies.html is my product URL: http://localhost.com/magento/hoodies.html and
then Select "redirect permanent 301" from the list "Redirect".
If the url is determined by a controller and an action you can use this:
{{store url="module/controller/action"}}
If the url is to a cms page you this:
{{store _direct="url-key-here"}}
if you want some query params also like /some-ulr?a=2&b=5
use one of the methods above and add a _query
parameter.
{{store url="module/controller/action" _query="a=2&b=5"}}
{{store _direct="url-key-here" _query="a=2&b=5"}}
[EDIT]
You can get the same urls in a template file like this:
$this->getUrl('module/controller/action'); //for controller pages
$this->getUrl('', array('_direct'=>'some-url-key')); //for cms pages
$this->getUrl('module/controller/action', array('_query'=>'a=2&b=5')); //for query params
$this->getUrl('', array('_direct'=>'some-url-key', '_query'=>'a=2&b=5')); //for query params
Best Answer
I think the answer given by Minesh in comments are partially correct. If you are trying to check it in your template file you can use below codes to check whether you are in category page, cms page or product page.
To check if you are in category page:
To check if it is a cms page:
To check if it is a product page:
From your comment, below code will let you know the last page url is either cms page, or category or product.
I hope this will help. If it works for you pleae don't forget to accept and vote the answer. This will help others too.
Happy Coding!!