Jump to content

URL Help...


amin1982

Recommended Posts

hey guys...

 

i'm not sure whether this is a problem with PHP but i may as well ask..

 

I am currently putting together a site which is database driven. I have however used Apaches Rewrite rule to create more friendly URL's.

 

However this does create problems when a user types an incorrect URL.

 

for example;

 

if you visit the link:

 

http://www.omaraguestlist.co.uk/v3/londonnightclub/24-London

 

you will see that this works fine.

 

however if the user miss-spells the URL like this:

http://www.omaraguestlist.co.uk/v3/londonnightclub/24-Londo

 

then you get taken to a pretty ugly page! More importantly if the user just types in:

 

http://www.omaraguestlist.co.uk/v3/londonnightclub

 

they receive the same page.

 

How can I..

 

1. Work round the misspelling of the URL so that it goes to the page I want it to this case it will be http://www.omaraguestlist.co.uk/v3/londonnightclubs.php

 

2. For the www.omaraguestlist.co.uk/v3/londonnightclub I have tried creating a directory within the FTP with an index file www.omaraguestlist.co.uk/v3/londonnightclub/index.php but this hasn't solved the problem!

 

Any ideas/solutions?!

 

Thanks

Link to comment
Share on other sites

 

RewriteEngine on

Options +FollowSymlinks

RewriteBase /

RewriteRule ^(login(/.*)?)$ londonnightclub.phtml?londonnightclub=$1 [QSA,L]

#RewriteRule ^[.*](/.*)?$ index.phtml?page=$1 [QSA,L]		#	EVERYTHING ELSE PASSED HERE
#RewriteRule ^((.*)?)$ index.phtml?page=$1 [QSA,L]		#	EVERYTHING ELSE PASSED HERE

# Customized error messages.
ErrorDocument 404 /index.phtml?page=404

I can't remember which of the everything else's is correct, but you should get the idea... Also give a basic 404...

Link to comment
Share on other sites

hey,

 

thanks for that but that didn't seem to work...

 

I've pretty much just copied and pasted what you suggested as I'm not too sure how the rewrite works...

 

How can i turn the code below:

 

Options +FollowSymLinks
RewriteEngine on
RewriteRule londonnightclub/(.*) londonnightclub.php?londonclub=$1

 

to work?

 

 

Link to comment
Share on other sites

hey,

 

i've moved my php tags around abit now i get a blank white screen... this might be abit cheeky but can you have a look at the code and let me know if I should add code or change something...

 

<?php 
require_once('includes/connect.php'); 
require_once ('includes/config.inc.php'); 
?>
<?php 

$problem = FALSE; 

if (!isset($_GET['urlName'])) {

$urlName = trim($_GET['urlName']);


$url = 'http://' . $_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF']);

if ((substr($url, -1) == '/') OR (substr($url, -1) == '\\') ) {
	$url = substr ($url, 0, -1); 
}

$url .= '/nightclubs.php';

ob_end_clean(); 
header("Location: $url");
exit(); 

} else { 

if (isset($_GET['urlName'])) {

$urlName= trim($_GET['urlName']);

$sql = "SELECT * FROM table1 WHERE urlName= '$urlName'";

$result = mysql_query($sql, $dbc) or die('Error, query failed');

if (mysql_num_rows($result)) { // Good to go!

$row = mysql_fetch_assoc($result);



?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title><?php echo "{$row['pageTitle']}"; ?></title>

<meta name="description" content="<?php echo "{$row['pageDescription']}"; ?>">
<meta name="keywords" content="<?php echo "{$row['pageKeywords']}"; ?>.">


<!-- CSS STYLE SHEET -->
<link rel="stylesheet" type="text/css" href="css/style.css"/>
<!--[if IE]>
<link rel="stylesheet" type="text/css" href="css/styleie7.css" />
<![endif]-->
<!-- CSS STYLE SHEET -->


</head>

<body>

<!-- start wrapper -->
<div id="wrapper">
<!-- elite logo -->
<div id="header"> <a href="home.php"><img src="images/logo.jpg" alt="Logo" width="110" height="100" border="0" /></a>
<!-- flash banner -->
</div>
<!-- elite logo -->
<ul class="menu">
<li><a href="home.php">Home</a></li>
<li><a href="parties.php">Elite Parties</a></li>
<li><a href="photogallery.php">Elite Photo Gallery</a></li>
<li><a href="nightclubs.php" class="current">Night Club Reviews</a></li>
<li><a href="party.php">Your Party</a></li>
<li><a href="press.php">Press</a></li>
<li><a href="restaurants.php">Restaurants</a></li>
<li><a href="rssfeeds.php">Elite RSS Feeds</a></li>
<li><a href="lifestyle.php">Elite Lifestyle</a></li>
</ul>
<br style="clear: left" />

<div id="main"><!-- start main -->

<!-- splits the page into 3 --><div id="columnsClubreviews">
<div id="inner">
<div id="leftClubreviews">
<div id="clubsList">
<span class="clubsList">
<strong>Night Club Reviews</strong>
<br>
<br>
<?php
$query = "SELECT * FROM `table` WHERE active='1' ORDER BY venue_name";
$result = mysql_query($query) or die('Error, query failed');
while ($list = mysql_fetch_array($result)) {
echo "<a href ='nightclub/{$list['urlName']}' >{$list['venue_name']}</a> <br>";
}
?>
</span>

</div>
<!-- end intro box -->
</div><!-- end left -->

<!-- start content -->
<div id="contentReviews">
<?php

echo "<h1 class='clubname'>{$row['venue_name']}</h1><br><br>";

echo "<div>{$row['venue_address']}</div><br><br>";

echo "<div>{$row['description']}</div><br><br>";

echo "Opening Times: {$row['openingTimes']}<br><br>";

echo "Nearest Tube: {$row['nearestTube']}<br><br>";
if ('' == $row['guestList'])
{
echo "Guest Lists: Currently Unavailable. For our current nights please <span class='text'><a href='#'>view our parties page</a></span> <br>";
}
else
{
echo "Guest Lists: <span class='text'><a href ='mailto:{$row['guestList']}'>{$row['guestList']}</a></span> <br>";
}

?>
<br />
<br />
<strong>Your Reviews of <? echo "{$row['venue_name']}" ?>:</strong>
<br>
<br>
<?php
$img_path = 'http://www.website.com/images/ratingStar.gif';
$query = "SELECT * FROM ec_reviews WHERE urlName='$urlName' AND approved='1'";
$result = mysql_query($query) or die('Error, query failed');
while ($list = mysql_fetch_array($result)) {

echo "Review by: {$list['name']}<br>";

echo "From: {$list['from']}<br>";

echo "Review: {$list['review']}<br>";

?>
Rating: <?
if ($list['rating'] > 0)
{
for ($i=0; $i<$list['rating']; $i++)
{
	echo "<img src='$img_path'> ";
}
}
//echo "Rating: {$list['rating']}<br><br>";
}
?>
<br />
<br />
<br />
<strong>Add Your own Reviews for <? echo "{$row['venue_name']}" ?>:</strong><br />
*Please fill in all fields

<script type="text/JavaScript" src="http://www.website.com/review.js"></script>
<form action="http://www.website.com/review.php" method="post" name="review" onsubmit="MM_validateForm('name','','R','from','','R','email','','RisEmail','review','','R');return document.MM_returnValue">
<p>
<label for="name">*Name:</label>
<input type="text" name="name" id="name" class="txt" />
</p>
<p>
<label for="from">*From:</label>
<input type="text" name="from" id="from" class="txt" />
</p>
<p>
<label for="email">*Email:</label>
<input type="text" name="email" id="email" class="txt" />
</p>
<p>
<label for="rating">*Rating:</label>
<select name="rating" class="box2" id="test">
<option>-- select --</option>
<option value="5">Fantastic</option>
<option value="4">Good</option>
<option value="3">Average</option>
<option value="2">Disappointing</option>
<option value="1">Poor</option>
</select>
</p>
<p>
<label for="comments">*Comments:</label>
<textarea name="review" cols="30" rows="4"></textarea>
</p>
<p>
<input type="hidden" name="urlName" id="urlName" value="<? echo "Review: {$row['urlName']}" ?>" />
<input type="hidden" name="submit" value="done" />
<input type="submit" name="submit" id="btnSubmit" value="Add Comment" class="btn" />
</p>
</form>
</div>
<!-- end content -->

<div id="rightClubreviews">
<div id="clubimages">
<ul>
<li id="t1"><img class="panelimage" src="<? echo "{$row['imageLogo']}";?>" alt="<? echo "{$row['venue_name']}";?>" width="190" height="126" /></li>
<li id="t1"><img class="panelimage" src="<? echo "{$row['image002']}";?>" alt="<? echo "{$row['venue_name']}";?>" width="190" height="126" /></li>
<li id="t1"><img class="panelimage" src="<? echo "{$row['image003']}";?>" alt="<? echo "{$row['venue_name']}";?>" width="190" height="126" /></li>
<li id="t1"><img class="panelimage" src="<? echo "{$row['image004']}";?>" alt="<? echo "{$row['venue_name']}"; 
?>
" width="190" height="126" /></li>
</ul>
</div>

</div>

<div id="googleAds">
<!-- Google -->
<script type="text/javascript"><!--
google_ad_client = "pub-0002635803656328";
google_ad_width = 120;
google_ad_height = 600;
google_ad_format = "120x600_as";
google_ad_type = "image";
google_ad_channel = "";
//--></script>
<script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
<!-- Google -->
</div>


</div>
<!-- end inner -->

</div><!-- end columns -->

</div><!-- end main -->

<!-- second half of page -->



<div class="clear"></div>

<?php include ("includes/footer.html"); ?>

</div><!-- end wrapper -->

</body>
<?
}
}
}
?>
</html>

 

thanks

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.