I have a set of urls like...
www.example.com/page/1/name/abc
www.example.com/city/la/name/abc
www.example.com/page/1/name/abc/city/la
www.example.com/page/1/
And want to convert them as..
www.example.com/1/abc
www.example.com/la/abc
www.example.com/1/abc/la
www.example.com/1/
Basically i want to hide keys from query string.
How to do this? Any Help?
Edit
I have different keys for every page and there are about 25 keys per page.
There are two main directive of this module: RewriteCond & RewriteRule . RewriteRule is used to rewrite the url as the name signifies if all the conditions defined in RewriteCond are matching. One or more RewriteCond can precede a RewriteRule directive.
htaccess rewrite rules can be used to direct requests for one subdirectory to a different location, such as an alternative subdirectory or even the domain root. In this example, requests to http://mydomain.com/folder1/ will be automatically redirected to http://mydomain.com/folder2/.
You can use Zend_Controller_Router_Route and/or Zend_Controller_Router_Route_Regex and define the routes
$route = new Zend_Controller_Router_Route(
':key/:city_name',
array(
'controller' => 'somecontroller',
'action' => 'pageAction'
),
array('key' => '^\d+$')
);
$router->addRoute('page', $route); // www.example.com/1/abc
$route = new Zend_Controller_Router_Route(
':key/:city_name',
array(
'controller' => 'somecontroller',
'action' => 'cityAction'
),
array('key' => '^\d+\w+$') // www.example.com/1a/abc
);
$router->addRoute('city', $route);
Front controller is a design pattern which maps uri through single point and Zend is using front controller pattern. This maping can be change at bootstrap.php. I googled and found this question which is pretty similar.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With