| |||||||
| Programming PHP, Perl, Ruby on Rails, AJAX, HTML, XHTML, CSS, JavaScript, MySQL and any other coding topics. |
![]() |
| | LinkBack | Thread Tools |
| | #1 (permalink) |
| NamePros Regular | Redirecting to a Sub-Domain I have a wordpress based website originally at some domain abc.com which i want to move to a subdomain abc.xyz.com . I have already set up a mirror at abc.xyz.com so I wanted to know if there was a way to redirect (301) every page on abc.com to the corresponding page on abc.xyz.com ? Thanks, Abhinav |
| |
| | #2 (permalink) |
| NamePros Regular | you have 2 choices, or you do with mod_rewrite from apache or you can eventually use php. put this on a index page on your "abc.com" ( index.php ) Code: <?php
// sets the new domain
$new_domain= "http://www.google.com/";
// gets the corrent requested url
$old_url = $_SERVER['REQUEST_URI'];
// the redirect part
header("Location: $new_domain.$old_url");
?>
hope this helps ( if you wanna try it go to http://www.egek.com/teste/ and it will redirect you to http://www.google.com/teste/ )
__________________ Joćo Fernandes Silva Selling : 19P.ORG - ARCADEHITS.ORG - AZIAN.NET - COREFANS.COM - CTUTORIALS.NET - DEDISEEK.COM - HITCHECK.COM - HOST15.COM - HOSTCUSTOMER.COM - LARGETIPS.COM - SCRIPTCANDY.COM - VISUALBOOK.NET - VOXVPS.COM / .NET - WALLPAPERSARENA.COM |
| |
| | #4 (permalink) |
| NamePros Regular | that code does that... just change the $new_domain= "http://www.google.com/"; to $new_domain= "http://abc.xyz.com/"; and abc.com/anything_here will go to abc.xyz.com/anything_here
__________________ Joćo Fernandes Silva Selling : 19P.ORG - ARCADEHITS.ORG - AZIAN.NET - COREFANS.COM - CTUTORIALS.NET - DEDISEEK.COM - HITCHECK.COM - HOST15.COM - HOSTCUSTOMER.COM - LARGETIPS.COM - SCRIPTCANDY.COM - VISUALBOOK.NET - VOXVPS.COM / .NET - WALLPAPERSARENA.COM |
| |
| | #6 (permalink) |
| NamePros Regular | 301 is via htaccess, i don't know how to do it, maybe someone else can help you with that.
__________________ Joćo Fernandes Silva Selling : 19P.ORG - ARCADEHITS.ORG - AZIAN.NET - COREFANS.COM - CTUTORIALS.NET - DEDISEEK.COM - HITCHECK.COM - HOST15.COM - HOSTCUSTOMER.COM - LARGETIPS.COM - SCRIPTCANDY.COM - VISUALBOOK.NET - VOXVPS.COM / .NET - WALLPAPERSARENA.COM |
| |
| | #7 (permalink) |
| Stud Sausage | I would have suggested an all .htaccess approach (mod_rewrite), however since you seem to have settled into php already ![]() You can use the header functions to modify headers sent, i.e. you can achieve the same effect as a 301 redirect using it. PHP Code: PHP Code: My, arguably better answer to this would be: (in .htaccess) Code: RewriteEngine On RewriteRule ^(.*)$ http://abc.xyz.com/$1 [R=301,L] Matt |
| |
| | #8 (permalink) |
| NamePros Regular | yes, agreed, via htaccess is better, but since i'm not very confortable at it i gave a quick answer.
__________________ Joćo Fernandes Silva Selling : 19P.ORG - ARCADEHITS.ORG - AZIAN.NET - COREFANS.COM - CTUTORIALS.NET - DEDISEEK.COM - HITCHECK.COM - HOST15.COM - HOSTCUSTOMER.COM - LARGETIPS.COM - SCRIPTCANDY.COM - VISUALBOOK.NET - VOXVPS.COM / .NET - WALLPAPERSARENA.COM |
| |
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| |