Jul 20, 2008

.htaccess Redirect Question - redirect ALL traffic to another domain

Free Web Hosting, No Ads > CONTRIBUTE > Computers > Programming Languages > PHP Programming

free web hosting

.htaccess Redirect Question - redirect ALL traffic to another domain

snlildude87
I want to redirect all my traffic from one site to another domain name. Is this possible, and if so, would I do something like this:

.htaccess code:
CODE
redirect 302 / http://www.mynewdomain.com


Thanks!

Reply

moldboy
Well, it seems to me that if you made your 404 error page so that it contined a javascript redirect that should do the trick.

Reply

Spectre
You have a couple of options, the simplest of which you have already mentioned (although I would recommend using a 301/permanent redirect over a 302/temporary equivalent). Note that you can use 'temp' or 'permanent' in place of the HTTP request codes.

Also try looking up the RewriteRule (or mod_rewrite)

Reply

Spectre
Oh, you can also redirect access via PHP, using the header() function:

CODE
// Permanent redirect:
header('HTTP/1.1 301 Moved Permanently', true);
header('Location: http://www.location.com/');
// Temporary redirect (note that sending the 'Location' header automatically sends a 302 redirect unless it is explicitly overwritten, as it is above):
header('Location: http://www.location.com/');

Reply

OpaQue
Cpanel gives you options for permanent and temporary redirect. Check it out at your Cpanel.

Reply

snlildude87
So basically, I could do it my way (stated in the first post) or I could write put headers into the pages that I want redirected?

By the way, what's the difference between permanent and temporary? I mean, if you put it at permanent (301), then you can always edit the php file, right? Then isn't that temporary?

Reply

Spectre
The idea is that a temporary redirect indicates that the original page is going to be restored at some stage soon, and a permanent redirect means it's not coming back (or at least, won't be there for an extended period). For example, if you are doing site maitainance and don't want any of your pages viewed during the process, you might '302' them to, say, '/message.html' to inform them of this. But if you renamed your page from '/page.html' to '/otherpage.html', you might want to permanently redirect traffic from the former to the latter.

Most search engines also treat 301 and 302 redirection very differently. If you change your site to another domain name, then it is generally a good idea to use permanent redirects to point to your new domain name, informing the search engine that your site has been moved.

Reply



Got an Opinion! Express your Views! (no registration):-
Add your Reply/ Opinion/ Views/ Comments/ Suggestion/ Questions/ Queries etc.
Posts with decent grammar & English will be accepted and please refrain from profanities.
For asking a Question, We recommend you to sign-up (for free) so that you can track the topic easily.

Nature of your Post*: Opinion/ Reply/ Comments
Question/Query
Feedback to us.
       
Name   Email
Title/Question*

(Maximum characters: 10,000)
You have characters left.
Confirm Code:

Recent Queries:-
  1. httaccess redirect site to another site - 4.97 hr back. (1)
  2. htaccess forward to another domain - 17.03 hr back. (1)
  3. redirect .htaccess all - 19.25 hr back. (1)
  4. my htaccess redirection isnt working - 32.34 hr back. (2)
  5. redirect all traffic with htaccess - 37.12 hr back. (1)
  6. htaccess redirect all - 21.28 hr back. (3)
Similar Topics

Keywords : htaccess redirect redirect traffic domain

  1. Http_redirect() [resolved] - (4)
  2. Problem With Page Redirect - Help me out with this problem... (7)
    hey ppl, i just wanted a little help...i designed this website, but i want that if i click on
    certain link, it should open new page for few seconds and then browser should automatically redirect
    me to some other page....i tried this with header() function but i couldnt do the wait n redirect
    part, ... so somebody plz help.... -thanx in advance! Thanks Avalon, topic changed. ...
  3. Header Redirect Errors - (5)
    Hi, I am using the header function to redirect after the processing of the form. I have to specify
    a internal link using '#link'. This works in Firefox and opera. But in Internet Explorer
    internal linking when done from a redirect is not working for somewhat reasons. e.g.
    header("Location: http://www.example.com/index.php#link"); this works in Firefox and Opera but
    not in Internet Explorer . IE just accepts 'http://www.example.com/index.php' instead of
    http://www.example.com/index.php#link Please help me if you know anything about this. Well ther...
  4. Sub Domain Help In Xampp - Sub Domain Help in xampp (4)
    I am trying to work out how to get subdomains working in xampp. I have tried all of the tutorials
    on the net but I still cant work it out. Any Ideas? Thanks Rob...
  5. [^] Need Help With Regex (for .htaccess) - (2)
    Well, I ran into a problem. I tried to make a code that matched everything, except strings
    containing the word "php", "gif", "jpg" etc. I tried doing something like this, but it didn't
    work: CODE ([^\b(php|gif|jpg)\b]+)$ But that works
    just like if I would do this: CODE ([^phgifj]+)$ That code is a part of
    a larger code that only works partially: CODE RewriteEngine on RewriteRule  
    ([^\b(php|gif|jpg)\b]+)$    item.php?n=$1 Some
    strings, su...
  6. .htaccess-style Login System And Php - (13)
    I am trying to make a login system that looks and works like .htaccess using sessions, with a PHP
    script that detects the username used. Let's say I log on with the username "Amezis" and
    correct password. Then I want a PHP (or any other kind of script) to create a cookie or session
    which stores the user name, so it could be possible to store it in a variable as long as the user is
    logged in, and so it can be printed when needed. Basically, this is what I want the script to do:
    CODE /* This file can only be executed after logging in with the htaccess-style login...
  7. Url Redirection - redirect a page web to another page (7)
    Hi Is there some functions in php to redirect a page web to another page. thanks...
  8. .htaccess Charset Problem... - (2)
    I have a problem with the charset in my php page... firstly the whole site included .html and .php
    didn't automaticly get the right charset i put in the meta content so I added a .htaccess file
    CODE AddDefaultCharset Big5 then it works fine with the .html file extension... but not my
    php file... so i added another line in .htaccess file CODE AddCharset Big5 .php but still
    not working... there is something i wondering... coz my link to the php file is "foo.php?A=B" would
    that be the problem that the .htaccess file dun see it as a normal .php? Pl...



Looking for htaccess, redirect, redirect, traffic, domain

Searching Video's for htaccess, redirect, redirect, traffic, domain
advertisement



.htaccess Redirect Question - redirect ALL traffic to another domain



 

 

 

 

ADD REPLY / Got an Opinion! Remove these ADs! RAPID SEARCH! Free Web Hosting [X]
Express your Opinions, Thoughts or Contribute more info. to help others.
Ask your Doubts & Queries to get answers, So that "Together We can help others!"
Register FREE for AD-FREE forum, Create your own topics, Ask Questions, track topics, setup subscriptions & notifications and Get a Free Website w/ Email and FTP.
500MB Space *No Ads*, CPanel, FTP, PHP, MySQL, EMails - 100% FREE