![]() |
How do you create this 301 redirect using PHP? I would like www enforced and file structure intact. e.g. subdomain[dot]domain[dot]com/bears[dot]php redirects to www[dot]newdomain[dot]com/bears[dot]php AND/OR subdomain[dot]domain[dot]com redirects to www[dot]newdomain[dot]com e.g. newdomain[dot]com/bats[dot]php redirects to www[dot]newdomain[dot]com/bats[dot]php AND/OR newdomain[dot]com redirects to www[dot]newdomain[dot]com How would I create a PHP(not .htaccess) redirect that incorporates both the examples above? Would I use an add-on domain? Or would a parked domain be better? *replace [dot] with . |
Re: How do you create this 301 redirect using PHP? Hi evilbone, What's the difference between a PHP and .htaccess 301 redirect? Why would you prefer the PHP version? I want to redirect all the 'non www' pages on my site to their 'www' counterparts. Which way do you think I should use? What do you think is better, www or no www? Thanks evilbone! |
Re: How do you create this 301 redirect using PHP? @evilbone, Its pretty simple, its the same as a normal redirect accept you include and extra line before: PHP Code: |
Re: How do you create this 301 redirect using PHP? @RokNStok Quote:
Quote:
Quote:
Quote:
@<CrGeary.com/> That code does take me to the new URL but doesn't load the same pages from the subdomain. See first example for what I mean. Were my questions in my first post not specific enough?:confused: |
Re: How do you create this 301 redirect using PHP? How about this? I use this to completely redirect to identical pages/directories $new_location = 'your-new-domain'.$_SERVER['REQUEST_URI']; Header( "HTTP/1.1 301 Moved Permanently" ); Header( "Location: $new_location" ); exit; |
| All times are GMT -6. The time now is 03:04 AM. |