Jump to content

Recommended Posts

The typical way that is done is to use mod_rewrite rules, assuming you are using apache. 

 

You also need some functional code that will translate an internal url you generate into a "rewritten" url, so that when you display links to locations in your site, they are presented in the SEO way.

 

In order for this to work, your site needs to have a url scheme in place where rules can be installed.  For example, you need something like:

 

?module=articles&action=show&slug=3-My-Site-is-launched

 

So that the rewrite rules can effectively break up your seo friendly url by position, and fill the module/action and id parameters from the SEO friendly url of:

 

http://yoursite.com/articles/show/3-My-Site-is-launched

 

There are lots of examples of making this work, not to mention that near every forum,blog and cms come with htaccess files that have robust implementations of these rules you can learn from by example.  Mod_rewrite rules require a basic understanding of regex, but there are countless tutorials around.

 

 

Link to comment
https://forums.phpfreaks.com/topic/229311-remove-from-url/#findComment-1181556
Share on other sites

here is the url  .php?id=89

I would really rather have it end with a better description from the database.

Is the a script issue or can it be done with .htaccess

 

please help

 

I am trying this but it does not work.

 

Options +FollowSymLinks

RewriteEngine on

 

RewriteRule show_detail/id/(.*) show_detail.php?id=$1

Link to comment
https://forums.phpfreaks.com/topic/229311-remove-from-url/#findComment-1182191
Share on other sites

<?php
include('../show_submits/includes/config.db.php');
if ($link)
{
  if ($_GET["id"])
  {
$id = $_GET["id"];
$sql = "select * from craft_shows where id = $id";
if (!empty($row['website'])) 
if (!empty($row['email']))  
$electricity = $row['electricity'];
if ($electricity == "1")  
{
$answer = "yes";
}
else
{
$answer = "no";
}

$acceptance_criteria = $row['acceptance_criteria'];
if ($acceptance_criteria == "1") 
{
$answer1 = "yes";
}
else
{
$answer1 = "no";
}




$setup_loc = $row['setup_loc'];
if ($setup_loc == "2")
{
$answer2 = "In and Outdoors";
}
elseif ($setup_loc == "1")
{
$answer2 = "Outdoors";
}
else

{

$answer2 = "Indoors";

}

$wares_ac = $row['wares_ac'];
if ($wares_ac == "2")
{
$answer3 = "Buyer/Wholesale and Retail";
}
elseif ($wares_ac == "1")
{
$answer3 = "Retail";
}
else

{

$answer3 = "Retail - Open to general public";

}


$result = mysql_query($sql) or die(mysql_error());
$row = mysql_fetch_array($result);
echo "<table class='table9'>";
echo "<tr>";
echo "<td class='det-B'>Type of show</td><td class='det-B'>";
echo $answer3;
echo "</td></tr>";
echo "<table class='table9'>";
echo "<tr>";
echo "<td class='det-A' width='120'>Venue Name</td><td class='det-A'>";
echo $row['venue_name'];
echo "</td></tr>";
echo "<tr>";
echo "<td class='det-B'>Address</td><td class='det-B'>";
echo $row['venue_address'];
echo "</td></tr>";
echo "<tr>";
echo "<td class='det-A'>City</td><td class='det-A'>";
echo $row['venue_city'];
echo "</td></tr>";
echo "<tr>";
echo "<td class='det-B'>State</td><td class='det-B'>";
echo $row['venue_state'];
echo "</td></tr>";
echo "<tr>";
echo "<td class='det-A'>Zip Code</td><td class='det-A'>";
echo $row['venue_zip'];
echo "</td></tr>";
echo "<tr>";
echo "<td class='det-B'>Start Date</td><td class='det-B'>";
echo strftime("%b %d, %Y", strtotime($row['start_date']));
echo "</td></tr>";
echo "<tr>";
echo "<td class='det-A'>End Date</td><td class='det-A'>";
echo strftime("%b %d, %Y", strtotime($row['end_date']));
echo "</td></tr>";
echo "<tr>";
echo "<td class='det-B'>Start Time</td><td class='det-B'>";
echo $row['start_time'];
echo "</td></tr>";
echo "<tr>";
echo "<td class='det-A'>End Time</td><td class='det-A'>";
echo $row['end_time'];
echo "</td></tr>";
echo "<tr>";
echo "<td class='det-B'>Contact</td><td class='det-B'>";
echo $row['contact_name'];
echo "</td></tr>";
echo "<tr>";
echo "<td class='det-A'>Phone</td><td class='det-A'>";
echo $row['phone'];
echo "</td></tr>";
echo "<tr>";
echo "<td class='det-B'>email</td><td class='det-B'>";
echo "<a href='mailto:".$row['email']."'>".$row['email']."</a>\n";
echo "</td></tr>";
echo "<tr>";
echo "<td class='det-A'>website</td><td class='det-A'>";
echo "<a href='".( strpos( '://', $row['website'] ) ? '' : '' ).$row['website']."'>".$row['website']."</a>\n";
echo "</td></tr>";
echo "<tr>";
echo "<td class='det-B'>Number of Crafters</td><td class='det-B'>";
echo $row['num_crafters'];
echo "</td></tr>";
echo "<tr>";
echo "<td class='det-A'>Booth Fee</td><td class='det-A'>";
echo $row['booth_fee'];
echo "</td></tr>";
echo "<tr>";
echo "<td class='det-B'>Booth Width</td><td class='det-B'>";
echo $row['booth_size_w'];
echo "</td></tr>";
echo "<tr>";
echo "<td class='det-A'>Booth Depth</td><td class='det-A'>";
echo $row['booth_size_d'];
echo "</td></tr>";
echo "<tr>";
echo "<td class='det-B'>Electricity Available</td><td class='det-B'>";
echo "$answer";
echo "</td></tr>";
echo "<tr>";
echo "<td class='det-A'>Elctricity Cost</td><td class='det-A'>";
echo $row['electricity_cost'];
echo "</td></tr>";
echo "<tr>";
echo "<td class='det-B'>Setup Locations</td><td class='det-B'>";
echo $answer2;
echo "</td></tr>";
echo "<tr>";
echo "<td class='det-A'>Juried</td><td class='det-A'>";
echo "$answer1";
echo "</td></tr>";
echo "<tr>";
echo "<td class='det-B'>Jury Fee</td><td class='det-B'>";
echo $row['jury_fee'];
echo "</td></tr>";
echo "<tr>";
echo "<td class='det-A'>Jury Requirments</td><td class='det-A'>";
echo $row['jury_req'];
echo "</td></tr>";
echo "<tr>";
echo "<td class='det-B'>Application Deadline</td><td class='det-B'>";
echo strftime("%b %d, %Y", strtotime($row['application_dead']));
echo "</td></tr>";
echo "<tr>";
echo "<td class='det-A'>Number of Visitors</td><td class='det-A'>";
echo $row['num_visitors'];
echo "</td></tr>";
echo "<tr>";
echo "<td class='det-B'>Special Comments</td><td class='det-B'>";
echo $row['comments'];
echo "</td></tr>";
echo "</table>";
}
}
?>

Link to comment
https://forums.phpfreaks.com/topic/229311-remove-from-url/#findComment-1182208
Share on other sites

That does not seem to be working either.

I sent an email to the host tech.  They said it was working at their end but I tested it with numerous browsers to no avail.

I even called a friend who had never loaded the site and it would not work for him.

 

I think I really would like the page to load with the show name instead of the id from the database but this may not be a mod rewrite issue.

Link to comment
https://forums.phpfreaks.com/topic/229311-remove-from-url/#findComment-1182346
Share on other sites

You have to get more specific about your definition of "not working".  Do you meant to say that when you use my rewrite rule and you have a url of http://www.yoursite.com/showdetail/id/1 it doesn't work?

 

If you want to pass a parameter that is not the id, that is doable.  Typically this is called a slug, but there is no magic to it. You need to create the slug and store it in a column that has a unique index on it, and use that in your WHERE clause rather than the id. 

 

You can see an example of this on my blog:  http://www.gizmola.com/blog/archives/105-Load-the-Url-symfony-helper-in-a-model-or-form-class.html

 

When an article is entered into the blog, it takes the titlle, converts spaces to dashes, and puts the id of the blog row as the first 3 characters to guarantee uniqueness in the case that i were to write 2 different entries with the same title.  The mod rewrite rules pass this parameter rather than the id of the blog entry, although if you employ a similar scheme you could just explode the string on '-' and use the first element as the id.

 

Either way that requires code.

Link to comment
https://forums.phpfreaks.com/topic/229311-remove-from-url/#findComment-1182490
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.