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…

  • Then I navigate my website and end up at…

(So far so good!!)

  • Now I click on the “Log In” link in the page header and end up at…
  • I log in successfully, and am routed back to the Article I was reading, but see a slightly different URL…

(Notice the extra / )

  • Now I click on the “Log Out” link in the page header and stay on the same page but see…
  • If I decide to log back in, I click on the “Log In” link in the page header and I go here as expected…
  • After logging in I am taken back to the Article I was reading and I see…
  • And if I log out I see…

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?!) :eek:



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.



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.

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

In “article.php” I have the 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

	// 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

	// ********************
	// Redirect Member.		*
	// ********************
	if (isset($_SESSION['returnToPage'])){
		header("Location: " . BASE_URL . $_SESSION['returnToPage']);
		// Take user to Home Page.
		header("Location: " . BASE_URL . "index.php");

Where BASE_URL is defined in my “” file as…

	// Base URL (**Virtual Location)
	define('BASE_URL', ENVIRONMENT === 'development'
					? 'http://local.debbie/'
					: '');

Does that help you out?


Here is what is in my .htaccess file…

# 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



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.



See Post #5 above…





Oh, you meant post #4.

define('BASE_URL', ENVIRONMENT === 'development'
                    ? 'http://local.debbie/'
                    : ''); 

yields (locally) http://local.debbie/

Apparently, your

 $_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.