Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 10-25-2011, 03:33 PM   PM User | #1
Ty44ler
New Coder

 
Join Date: Feb 2008
Posts: 57
Thanks: 8
Thanked 0 Times in 0 Posts
Ty44ler is an unknown quantity at this point
Replacing one word for entire site depending on the URL.

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!
Ty44ler is offline   Reply With Quote
Old 10-25-2011, 04:37 PM   PM User | #2
Spookster
Supreme Overlord


 
Spookster's Avatar
 
Join Date: May 2002
Location: Marion, IA USA
Posts: 6,222
Thanks: 4
Thanked 80 Times in 79 Posts
Spookster will become famous soon enough
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(); ?>
__________________
Spookster
CodingForums Supreme Overlord
All Hail Spookster
Who gave you that Ugging infraction? Yeah that's right it was me!
Spookster is offline   Reply With Quote
Old 10-25-2011, 05:04 PM   PM User | #3
resdog
Regular Coder

 
Join Date: Aug 2011
Location: U.S.A.
Posts: 233
Thanks: 2
Thanked 48 Times in 48 Posts
resdog is on a distinguished road
PHP Code:
<?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.
__________________
WordPress Designer and theme developer. KlongDesigns - helping bloggers and non-technical folks claim their space on the internet.
resdog is offline   Reply With Quote
Reply

Bookmarks

Tags
entire, replace, site, url, word

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 02:37 PM.


Advertisement
Log in to turn off these ads.