SitePoint Sponsor

User Tag List

Results 1 to 7 of 7
  1. #1
    SitePoint Wizard billy_111's Avatar
    Join Date
    Jul 2009
    Posts
    1,683
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    .htaccess file links still show .php

    Hi,

    I have the following .htaccess file:

    PHP Code:
    RewriteEngine on
    RewriteBase 
    /

    RewriteRule ^homeloginhttp://www.prima.cse.salford.ac.uk:8080/~ibrarhussain/index.php [L]
    RewriteRule ^homepagehttp://www.prima.cse.salford.ac.uk:8080/~ibrarhussain/view/index.php [L] 
    Now if i try visiting this link:

    http://www.prima.cse.salford.ac.uk:8...sain/homelogin

    The URL should stay the same, yet instead it changes back to index.php..?

    Why is this?

    How can i fix this?

    Thanks
    Software Engineer ASP, ASP.NET, VB, PHP

    Kind regards
    Billy

  2. #2
    Certified Ethical Hacker silver trophybronze trophy dklynn's Avatar
    Join Date
    Feb 2002
    Location
    Auckland
    Posts
    14,653
    Mentioned
    19 Post(s)
    Tagged
    3 Thread(s)
    b111,

    The reason is very clear to me: You are using an external absolute redirect which, by definition, will be displayed in the browser's location box. That's the why answer. The "how to" answer is to make the links internal and relative, i.e., (eliminate the red code - assuming that your .htaccess is in the ~ibrarhussain directory):
    Code:
    RewriteEngine on
    RewriteBase /
    
    RewriteRule ^homelogin$ http://www.prima.cse.salford.ac.uk:8080/~ibrarhussain/index.php [L]
    RewriteRule ^homepage$ http://www.prima.cse.salford.ac.uk:8080/~ibrarhussain/view/index.php [L]
    If you need more information about mod_rewrite, try starting at the tutorial article linked in my signature.

    Regards,

    DK
    David K. Lynn - Data Koncepts is a long-time WebHostingBuzz (US/UK)
    Client and (unpaid) WHB Ambassador
    mod_rewrite Tutorial Article (setup, config, test & write
    mod_rewrite regex w/sample code) and Code Generator

  3. #3
    SitePoint Wizard billy_111's Avatar
    Join Date
    Jul 2009
    Posts
    1,683
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hey,

    Thanks, i have looked at phpinfo() and have looked the the Apache2Handler, the loaded modules consist of:

    core mod_log_config mod_logio prefork http_core mod_so mod_alias mod_auth_basic mod_authn_file mod_authz_default mod_authz_groupfile mod_authz_host mod_authz_user mod_autoindex mod_cgi mod_dav mod_dav_fs mod_dav_svn mod_authz_svn mod_dir mod_env mod_mime mod_python mod_negotiation mod_php5 mod_rewrite mod_setenvif mod_status mod_userdir
    mod_rewrite is listed so this should work:

    PHP Code:
    RewriteEngine on

    RewriteRule 
    ^homeloginindex.php [L
    But again if i visit this page, the url remains the same:

    http://www.prima.cse.salford.ac.uk:8...sain/homelogin

    What could the problem possibly be?

    Thanks again,
    Software Engineer ASP, ASP.NET, VB, PHP

    Kind regards
    Billy

  4. #4
    SitePoint Wizard billy_111's Avatar
    Join Date
    Jul 2009
    Posts
    1,683
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Could it be a server issue?

    I need to work out why this is happening, i had to change the .htaccess file back to this:

    PHP Code:
    RewriteEngine on

    RewriteRule 
    ^homeloginhttp://www.prima.cse.salford.ac.uk:8080/~ibrarhussain/index.php [L]
    RewriteRule ^homepagehttp://www.prima.cse.salford.ac.uk:8080/~ibrarhussain/view/index.php [L] 
    As it was redirecting to an unknown page if i kept it as this:

    PHP Code:
    RewriteRule ^homeloginindex.php [L
    Can anyone kindly help me out please?

    Thanks
    Software Engineer ASP, ASP.NET, VB, PHP

    Kind regards
    Billy

  5. #5
    Certified Ethical Hacker silver trophybronze trophy dklynn's Avatar
    Join Date
    Feb 2002
    Location
    Auckland
    Posts
    14,653
    Mentioned
    19 Post(s)
    Tagged
    3 Thread(s)
    Billy,

    The only possible problem with
    Code:
    RewriteEngine on
    
    RewriteRule ^/?homelogin$ index.php [L]
    RewriteRule ^/?homepage$ view/index.php [L]
    ... is where DocumentRoot is located (above your personal directory) and where the .htaccess file is located (in your personal directory).

    DocumentRoot is important as it means that your RewriteBase / made all your redirections relative to the server's DocumentRoot - UNDESIRABLE! It also impacts the leading / for subdirectories so you could use ^/? at the start of any regex which addresses the URI starting with your directory.

    The .htaccess file's location is important as all the regex and redirections are relative to that.

    Regards,

    DK
    David K. Lynn - Data Koncepts is a long-time WebHostingBuzz (US/UK)
    Client and (unpaid) WHB Ambassador
    mod_rewrite Tutorial Article (setup, config, test & write
    mod_rewrite regex w/sample code) and Code Generator

  6. #6
    SitePoint Wizard billy_111's Avatar
    Join Date
    Jul 2009
    Posts
    1,683
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ok thanks,

    On the server, i have the following folders:

    bin
    dev
    etc
    lib
    lib64
    public_html
    usr
    Then inside of the public_html folder i have:

    admin
    library
    model
    view
    .htaccess
    index.php
    Is this the correct location for the .htaccess file?

    I have also tried using the following 2 techniques:

    PHP Code:
    RewriteRule ^/?homeloginhttp://www.prima.cse.salford.ac.uk:8080/~ibrarhussain/index.php [L]
    RewriteRule ^/?homeloginindex.php [L
    But neither work for me. When i type in the link homelogin it directs perfectly. The only problem is that the link name should say homelogin but instead says index.php

    What am i doing wrong? How could i find out exactly where the problem is?
    Software Engineer ASP, ASP.NET, VB, PHP

    Kind regards
    Billy

  7. #7
    Certified Ethical Hacker silver trophybronze trophy dklynn's Avatar
    Join Date
    Feb 2002
    Location
    Auckland
    Posts
    14,653
    Mentioned
    19 Post(s)
    Tagged
    3 Thread(s)
    Billy,

    Please READ post #2.

    Regards,

    DK
    David K. Lynn - Data Koncepts is a long-time WebHostingBuzz (US/UK)
    Client and (unpaid) WHB Ambassador
    mod_rewrite Tutorial Article (setup, config, test & write
    mod_rewrite regex w/sample code) and Code Generator


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
  •