...

View Full Version : Replacing one word for entire site depending on the URL.



Ty44ler
10-25-2011, 03:33 PM
I have two domains. I'd like to replace a word depending on the URL the user has typed in.

For example:
Original site is all about red pens. Well I want to make another domain that is bluepens.com, but when they enter in bluepens.com it uses the same pages from red pens except wherever the word 'red' is found it is changed to blue pens making it a whole new site.

I know I can use str_replace() for certain instances, but how would you do it for an entire website using the url?

Thanks!

Spookster
10-25-2011, 04:37 PM
Just create an include file that is included in all pages you need to do this on. Write a function and that checks the URL and returns a string containing the appropriate data for the selected site. Then wherever you need that string printed just put <?php echo myFunction(); ?>

resdog
10-25-2011, 05:04 PM
<?php if ($_SERVER['SERVER_NAME'] == 'www.yoururl.com') {
$wordchange = 'new Words';
} else {
$wordchange = 'default Words';
}
?>


Like Spookster said, add this to an include on all your pages. Then call the variable to replace the word you are wanting to use.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum