I'm having trouble with embedded page links on a mobile site I've inherited. The CMS obviously wants to use the desktop site for all its page links, which is taking people way from the mobile version. I'm a complete n00b in CFML and I'm sure it's pretty simple, but I need to get every link on the page that currently shows as:
to be replaced with:
http://www.example.com/mobile/
I looked at REGEX and my brain melted. Please can someone show me how to do a replace for this? Thank you :)
PS I don't have application.cfm in the /mobile folder where I would expect to specify a new domain like this. I tried it but on clearing the cache it hangs the site so I've had to remove it.
To avoid further overcomplication, I mixed it up with jQuery...
<script type="text/javascript">
$(document).ready(function() {
$("a[href^='/']").each(function(){
var cur_href = $(this).attr("href");
if( cur_href.indexOf( "http" ) !== -1 ) {
$(this).attr("href", cur_href);
} else {
$(this).attr("href", '/mobile'+cur_href);
}
});
});
</script>
The links turned out to be relative, else it would have been one line of code using the application domain variable.