mod_rewrite and client side JS

Not for 'how-to' coding questions but PHP theory instead, this forum is here for those of us who wish to learn about design aspects of programming with PHP.

Moderator: General Moderators

Post Reply
alex.barylski
DevNet Evangelist
Posts: 6267
Joined: Tue Dec 21, 2004 5:00 pm
Location: Winnipeg

mod_rewrite and client side JS

Post 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 :)
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Hockey wrote:Hopefully I made sense, I've hammered this out in quite a rush
Not to me. :|
User avatar
Luke
The Ninja Space Mod
Posts: 6424
Joined: Fri Aug 05, 2005 1:53 pm
Location: Paradise, CA

Post by Luke »

me neither
User avatar
Kieran Huggins
DevNet Master
Posts: 3635
Joined: Wed Dec 06, 2006 4:14 pm
Location: Toronto, Canada
Contact:

Post 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.
Post Reply