Htaccess redirection problem

Discussion in 'PHP' started by sunil_23413, Jun 19, 2009.

  1. #1
    I am using htaccess to redirect url on a live server. My htaccess file are working well on localhost but giving problem on live server.
    It shows an error like “/home/a1pro/public_html/euterpedia.com/a1/show.php not found on server”.
    What I guessed form the above error message is that “a1pro” should be “~a1pro” as my site url is http://64.34.170.31/~a1pro/euterpedia.com/.

    Then I echo $_SERVER['SCRIPT_FILENAME'] variable it displayed like
    /home/a1pro/public_html/euterpedia.com/artist_list/index.php
    But I think it should display /home/~a1pro/public_html/euterpedia.com/artist_list/index.php as my site url is http://64.34.170.31/~a1pro/euterpedia.com/
     
    sunil_23413, Jun 19, 2009 IP
  2. stOK

    stOK Active Member

    Messages:
    114
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    53
    #2
    What does .htaccess contain?
     
    stOK, Jun 19, 2009 IP
  3. Louis11

    Louis11 Active Member

    Messages:
    783
    Likes Received:
    26
    Best Answers:
    0
    Trophy Points:
    70
    #3

    The
    is the directory on the (li)nix machine, called your physical path. That is, if you had SSH access to this particular computer and you navigated to that directory, then you would be able to see your file(s). You should not be attempting to access the files in this manner, as they are not available through the internet (or at least people shouldn't be able to access files like that on a properly setup system).

    In either case, you should be accessing the files using your IP address with your username:

    Have a look at Rewrite_Base, which lets "the server know that we [want the file] reached via /xyz and not via the physical path prefix /abc/def".

    
    #
    #  /abc/def/.htaccess -- per-dir config file for directory /abc/def
    #  Remember: /abc/def is the physical path of /xyz, i.e., the server
    #            has a 'Alias /xyz /abc/def' directive e.g.
    #
    
    RewriteEngine On
    
    #  let the server know that we were reached via /xyz and not
    #  via the physical path prefix /abc/def
    RewriteBase   /xyz
    
    #  now the rewriting rules
    RewriteRule   ^oldstuff\.html$  newstuff.html
    
    Code (markup):
     
    Louis11, Jun 19, 2009 IP
  4. webhostguy

    webhostguy Peon

    Messages:
    31
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    You can do a mod_rewrite and that should solve the issue. You can also do a php header to forward the domain.
    .htaccess
    
    Redirect 301 / http://www.new-site.com/
    
    Code (markup):
    PHP
    
    <?php
    header('Location: http://www.domain.com');
    ?>
    
    Code (markup):
     
    webhostguy, Jun 19, 2009 IP