Page 1 of 1

mod_rewrite and client side JS

Posted: Tue Feb 20, 2007 1:15 pm
by alex.barylski
HTML processed by PHP it's quite easy to switch between SEO friendly links or not, but JS is a whole different ball game.

For instance, assume you have a drop menu which generates it's links and when you initially coded your site you used URL such as

Code: Select all

index.php?page=aboutus
You later make everything SEO friendly so links generated on the backend comeout as

Code: Select all

/aboutus.html
Is there a way using mod_rewrite or some other technique which can be used for backwards compatability with existing javascripts?

Hopefully I made sense, I've hammered this out in quite a rush :)

Cheers :)

Posted: Tue Feb 20, 2007 4:35 pm
by feyd
Hockey wrote:Hopefully I made sense, I've hammered this out in quite a rush
Not to me. :|

Posted: Tue Feb 20, 2007 4:37 pm
by Luke
me neither

Posted: Tue Feb 20, 2007 10:42 pm
by Kieran Huggins
If I understand you properly, you would have to build a set of regexps that reverse what your mod_rewrite rules do.

I suggest... jQuery! (go figure)

Code: Select all

$(function(){
   $('a').val('href',$(this).val('href').replace(/^((http:\/\/yoursite\.com)?(\/?[\w\d-_\.\/?]*)\?(action1|action2)=(^&))/i,"$3/$4/$5"));
});
...or something like that.