May 13, 2011

How to use jquery rewrite redirect url

Question by user610983

I created a drop down list(with javascript onchange features), I would like to rewrite the redirect url from this: http://localhost/en/abc/kk.php?CT=1 to http://localhost/abc/kk.php?lang=en&CT=1 by using jquery.

Possible to do it?

Answer by Starx

You cannot rewrite the redirect url through clientside script such as javascript itself. You need .htaccess file to do so.

However, if the urls http://localhost/en/abc/kk.php?CT=1 is already present in your markup like in anchor tags

<a href="http://localhost/en/abc/kk.php?CT=1">Some Link Text</a>

Then you can use jQuery to change the value

$(document).ready(function() {
    $("a").attr("href","http://localhost/abc/kk.php?lang=en&CT=1");
    //It is better to replace the values using pattern mathcing
});
...

Please fill the form - I will response as fast as I can!