SitePoint Sponsor

User Tag List

Results 1 to 9 of 9
  1. #1
    SitePoint Wizard DoubleDee's Avatar
    Join Date
    Aug 2010
    Location
    Arizona
    Posts
    3,777
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)

    Geeting tons of //////// in my URLs

    I am getting a bunch of forward slashes in my URL when I log in and log out?!

    Here is what happens...

    - Let's say I start on the Home Page.

    - I would see...
    Code:
    http://local.debbie/index.php
    - Then I navigate my website and end up at...
    Code:
    http://local.debbie/articles/postage-meters-can-save-you-money
    (So far so good!!)

    - Now I click on the "Log In" link in the page header and end up at...
    Code:
    http://local.debbie/members/log_in.php
    - I log in successfully, and am routed back to the Article I was reading, but see a slightly different URL...
    Code:
    http://local.debbie//articles/article.php?slug=postage-meters-can-save-you-money
    (Notice the extra / )

    - Now I click on the "Log Out" link in the page header and stay on the same page but see...
    Code:
    http://local.debbie///articles/article.php?slug=postage-meters-can-save-you-money
    - If I decide to log back in, I click on the "Log In" link in the page header and I go here as expected...
    Code:
    http://local.debbie/members/log_in.php
    - After logging in I am taken back to the Article I was reading and I see...
    Code:
    http://local.debbie////articles/article.php?slug=postage-meters-can-save-you-money
    - And if I log out I see...
    Code:
    http://local.debbie/////articles/article.php?slug=postage-meters-can-save-you-money
    What in the world is going on?!

    (Everything seems to be working, but I know I'll get "blacklisted" if Google sees what my URL's are doing to their indexes?!)


    Debbie

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

    You don't say how you're linking the login or return and they're obviously what are adding the /'s. Show the code you're using if you really want the help.

    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
    Twitter: @TimIgoe silver trophy TimIgoe's Avatar
    Join Date
    Feb 2005
    Location
    Blackpool, UK
    Posts
    1,057
    Mentioned
    27 Post(s)
    Tagged
    1 Thread(s)
    I'm going to guess in one of your re-write rules, its testing for /something, but then adding an extra / to teh start of "/something" when it does the re-write itself.

    As has been said, show us and we'll be able to help more.

  4. #4
    SitePoint Wizard DoubleDee's Avatar
    Join Date
    Aug 2010
    Location
    Arizona
    Posts
    3,777
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by dklynn View Post
    DD,

    You don't say how you're linking the login or return and they're obviously what are adding the /'s. Show the code you're using if you really want the help.

    Regards,

    DK

    Not sure if I understand what you want to see, but here goes...

    In "article.php" I have the code...
    PHP Code:
        // ******************************
        // Attempt to Retrieve Article.    *
        // ******************************
        
    if (isset($_GET['slug']) && $_GET['slug']) {
            
    // Slug found in URL.

            // Set variable.
            
    $slug $_GET['slug'];

            
    // ************************
            // Find Article Record.        *
            // ************************

            // Connect to the database.
            
    require_once(WEB_ROOT 'private/mysqli_connect.php');

            
    // Set current Script Name.
            
    $_SESSION['returnToPage'] = $_SERVER['SCRIPT_NAME'] . '?slug=' $slug

    My "log_in.php" script is pretty involved so I won't post it all here, but it basically does this upon being submitted...

    - Validate Form Data
    - Find Member Email
    - Verify Activation
    - Validate Salt
    - Create Hash
    - Compare Stored Hash to Calculated Hash
    - Change "logged_in" field to "TRUE" in database
    - Set Session Variables
    PHP Code:
        // Verify Update.
        
    if (mysqli_stmt_affected_rows($stmt2)==1){
            
    // Update Succeeded.
            // Set Session variables.
            
    $_SESSION['memberID'] = $memberID;                                        //PURPOSE???
            
    $_SESSION['memberFirstName'] = $memberFirstName;
            
    $_SESSION['loggedIn'] = $loggedIn
    - Redirect User back to ReturnToPage
    PHP Code:
        // ********************
        // Redirect Member.        *
        // ********************
        
    if (isset($_SESSION['returnToPage'])){
            
    header("Location: " BASE_URL $_SESSION['returnToPage']);
        }else{
            
    // Take user to Home Page.
            
    header("Location: " BASE_URL "index.php");
        } 

    Where BASE_URL is defined in my "config.inc.php" file as...
    PHP Code:
        // Base URL (**Virtual Location)
        
    define('BASE_URL'ENVIRONMENT === 'development'
                        
    'http://local.debbie/'
                        
    'http://www.MySite.com/'); 

    Does that help you out?


    Debbie

  5. #5
    SitePoint Wizard DoubleDee's Avatar
    Join Date
    Aug 2010
    Location
    Arizona
    Posts
    3,777
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by TimIgoe View Post
    I'm going to guess in one of your re-write rules, its testing for /something, but then adding an extra / to teh start of "/something" when it does the re-write itself.

    As has been said, show us and we'll be able to help more.
    Here is what is in my .htaccess file...

    Code:
    # Build Date: 2012-01-03 2:20pm
    
    RewriteEngine on
    
    #PRETTY:		articles/postage-meters-can-save-you-money
    #UGLY:			article.php?slug=postage-meters-can-save-you-money
    
    #RewriteRule articles/([a-zA-Z0-9_-]+)$ article.php?slug=$1
    
    RewriteRule articles/([a-zA-Z0-9_-]+)$ articles/article.php?slug=$1

    Debbie

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

    What's the BASE_URL and how is it defined, with a trailing /, I'll bet.

    BTW, moderators, this is a PHP problem, not a server question.

    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

  7. #7
    SitePoint Wizard DoubleDee's Avatar
    Join Date
    Aug 2010
    Location
    Arizona
    Posts
    3,777
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by dklynn View Post
    DD,

    What's the BASE_URL and how is it defined, with a trailing /, I'll bet.

    DK
    See Post #5 above...


    Debbie

  8. #8
    SitePoint Wizard DoubleDee's Avatar
    Join Date
    Aug 2010
    Location
    Arizona
    Posts
    3,777
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Anyone??


    Debbie

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

    Oh, you meant post #4.

    Code:
    define('BASE_URL', ENVIRONMENT === 'development'
                        ? 'http://local.debbie/'
                        : 'http://www.MySite.com/');
    yields (locally) http://local.debbie/

    Apparently, your

    Code:
     $_SESSION['returnToPage'] = $_SERVER['SCRIPT_NAME'] . '?slug=' . $slug;
    is returning a value with a leading /. Go to a new page and echo the value of $_SERVER['SCRIPT_NAME'] to confirm ... then remove the trailing / from your DEFINE statement.

    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
  •