Results 1 to 5 of 5

Thread: redirect using .htaccess and ModRewrite

  1. #1
    Join Date
    Apr 2006
    Posts
    584
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default redirect using .htaccess and ModRewrite

    Hi All,

    I am having a massive issue trying to re-direct my site. I can get modRewrite working on my server but this is exactly what i need to happen.

    I have 2 domains pointing to my server:

    http://www.domain.com (primary domain)
    http://www.domain.com.au

    If a user types in http://www.domain.com.au, I want it to automatically re-direct to http://www.domain.com... I know I do this using .htaccess and modRewrite just not sure of the exact code...

    Any help would be fantastic! As I am stuck!

    Thanks,
    Tom

  2. #2
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    .htacess? you could just use php headers, or a meta tag. might be easier.

    Unless you're doing this so that

    domain1.com/particularpage.htm
    will redirect to
    domain2.com/particularpage.htm

    If you do want the exact location transferred, not sure how this works. you might be on the right track.

    Sorry, but I don't really know how to help with htaccess. good luck, though.

    if you did just want the second domain's index to transfer people, you could just use this, though:
    <meta http-equiv="refresh" content="0;url=http://www.domain.com">
    Put that in the header section, and you're done. 0 is the delay, in seconds, so for immediate redirect, use that.
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  3. #3
    Join Date
    Dec 2004
    Location
    UK
    Posts
    2,358
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by tomyknoker
    If a user types in http://www.domain.com.au, I want it to automatically re-direct to http://www.domain.com... I know I do this using .htaccess and modRewrite just not sure of the exact code...
    You needn't go as far as using mod_rewrite, and even if you did, mod_rewrite works very differently at a per-directory level (.htaccess) than it does in the server configuration file. The Redirect directive should suffice:

    Code:
    Redirect permanent / http://www.domain.com/
    Hope that helps,
    Mike

  4. #4
    Join Date
    Apr 2006
    Posts
    584
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Hi Mike,

    SO where about's do I put the code you spoke of? Does it go into a .htaccess file?

  5. #5
    Join Date
    Dec 2004
    Location
    UK
    Posts
    2,358
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by tomyknoker
    SO where about's do I put the code you spoke of? Does it go into a .htaccess file?
    Yes, though the main server configuration file would be better.

    Mike

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •