We Recommend

Wicked Cool PHP: Real-World Scripts That Solve Difficult Problems Wicked Cool PHP: Real-World Scripts That Solve Difficult Problems
Wicked Cool PHP contains a wide variety of scripts to process credit cards, check the validity of email addresses, template HTML, and serve dynamic images and text.


Posted By

lfatr on 06/13/08


Tagged

redirect


Versions (?)


Who likes this?

1 person has marked this snippet as a favorite

basicmagic


php redirect domain including subs & arguments


Published in: PHP 


i used this as an include on every page to redirect every page incl arguments from .com to .de

  1. // redirects -------------------------------------------------------------------------------------------------------------
  2. $page = new page;
  3. $new_url = str_replace("www.domain.com", "www.domain.de", $page->page, $count);
  4. if ( $count >= 1 ) { $page->redirect($new_url); }
  5. // redirects end ---------------------------------------------------------------------------------------------------------
  6.  
  7. class page {
  8. var $page;
  9. function page() {
  10. $this->page = "http://".$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI'];
  11. }
  12.  
  13. function redirect($href) {
  14. header("location: ".$href);
  15. exit();
  16. }
  17. }

Report this snippet 

You need to login to post a comment.