Vince Kronlein Vince Kronlein - 1 year ago 132
PHP Question

Dynamically Parse URL in .htaccess

Is it possible to do an odd and even replacement in

to replace
in a url with
= &

In other words I have a link like so:


and I'm wondering if there's way to simply replace the odd numbered
and the even

I have some urls that are very long with lots of arguments and I don't want to have to write a specific rule for each one.

I'm trying to convert over a very large PHP script to nicely formatted urls and it would take weeks to find every possible url and argument combination.

Answer Source

Why don't you want to make it in PHP script itself? I think I saw this for the first time in Zend framework, but now using similar approach in my projects.


RewriteEngine on
RewriteRule .* index.php


$path = $_SERVER['REQUEST_URI'];
$paths = explode('/', path);
// Add some logic for showing the page you need. Maybe remove domain before processing

For example you can use even arguments as array keys and add argument as value for these keys.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download