PHP & .htaccess

Discussion in 'PHP' started by dinrock, Apr 9, 2009.

  1. #1
    I have a windows server hosting my site. I asked them the following question:

    I want to change my http://www.danscartoons.com/ in the .htaccess file to
    http://danscartoons.com/ via the Advance mod_rewrite function.


    Here is the answer from their tech support:

    This is not possible as mod_rewrite is only available on our unix servers
    and your site is on a windows server.

    You can search for "php redirect" or "asp redirect" on a search engine to
    find information on how to do this using php or asp.


    Anything I can do to work around this? Btw, my host's server already allows a PHP script that controls the rotation of a daily image on my site.
     
    dinrock, Apr 9, 2009 IP
  2. koko5

    koko5 Active Member

    Messages:
    394
    Likes Received:
    14
    Best Answers:
    1
    Trophy Points:
    70
    #2
    You can use also meta refresh or javascript redirection.

    
    <?php
    header('Location: site.com');
    exit;
    ?>
    
    PHP:
    Cheers
     
    koko5, Apr 9, 2009 IP
  3. dinrock

    dinrock Well-Known Member

    Messages:
    1,150
    Likes Received:
    13
    Best Answers:
    0
    Trophy Points:
    128
    #3
    Hi Koko:
    So I would make it look like this?:

    <?phpheader('Location: http://danscartoons.com/');exit;?>

    And put this code into my site on the server?
    (note forward slash after the dot com)
     
    dinrock, Apr 9, 2009 IP
  4. koko5

    koko5 Active Member

    Messages:
    394
    Likes Received:
    14
    Best Answers:
    1
    Trophy Points:
    70
    #4
    Hi dinrock

    Only do not miss interval after php-open tag, but yes, it can be placed on one line:
    <?php header('Location: http://danscartoons.com/');exit;?>
    PHP:
    Regards
     
    koko5, Apr 9, 2009 IP
  5. ez-designs

    ez-designs Well-Known Member

    Messages:
    230
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    105
    #5
    I think what he's trying to do is make the non-www be his canonical address. The only thing I can think of is mod_rewrite. It only works on UNIX-based systems like you said.

    But in any case you want to switch servers:

    
    RewriteEngine on
    RewriteCond %{HTTP_HOST} .
    RewriteCond %{HTTP_HOST} !^http://www\.danscartoons.com/
    RewriteRule (.*) http://http://www.danscartoons.com//$1 [R=301,L]
    
    Code (markup):
     
    ez-designs, Apr 9, 2009 IP