View Full Version : Search Engine Friendly URL's - Directives
Hi,
I am trying to understand how to create a script like http://www.websitepublisher.net/article/search_engine_friendly_urls/3.
The bit I don't understand is "placing directives inside containers". I don't get how you put it in it, as there aren't any brackets or anything.
Could somebody help?
Thanks,
Mike:)
Chris
11-02-2003, 07:54 AM
Ahh... because containers look like HTML tags the browser is rendering those tags... I will fix it.
Fixed.
Didn't know it was a bug:)
Anyway, would you place the directives inside it like...?
<Files article>
ForceType application/x-httpd-php
article
</Files>
Doesn't look right, but it's the only way I can think of.
Thanks a lot,
Mike
Chris
11-02-2003, 10:47 AM
<Files article>
ForceType application/x-httpd-php
</Files>
Exactly like that. You're applying this directive to a single file "article"
Ah I somehow missed the article part of the fist line:p
Thanks for your help...
Mike
Coming back onto search engine friendly urls...
If you link like this, example.com?page=user, how would you link using method three? And if your doing a query like:
$result = mysql_query("SELECT * FROM games WHERE Name='$game'",
...how would you do it with search engine friendly urls?
Thanks a lot,
Mike:)
Chris
11-17-2003, 03:36 PM
use a url like
http://www.example.com/game/halflife/
$var_array = explode("/",$REQUEST_URI);
$var = $var_array[1]; // contents of variable are "halflife"
$result = mysql_query("SELECT * FROM games WHERE Name='$halflife";
incka
11-18-2003, 12:30 AM
As this got something to do with my site?
Ok, so to list all the links on a page you'd have something like...?
$result = mysql_query("SELECT * FROM games");
for ($x=0; $x < mysql_num_rows($result); $x++) {
$row = mysql_fetch_assoc($result);
echo ("<a href='http://www.example.com/game/");
echo $row['Name'];
echo ("'>")
}
And to have the game on the next page have something like this, and the echo statements?
$var_array = explode("/",$REQUEST_URI);
$var = $var_array[1];
$result = mysql_query("SELECT * FROM games WHERE Name='$var";
Also what is $REQUEST_URI please?
Thanks a lot for all your help,
Mike
chromate
11-18-2003, 11:34 AM
That looks about right Mike.
Be careful with your Syntax though. You're missing a few quotes, brackets and semi-colons. I know you'd pick that up in the final script though.
Also, try:
$result = mysql_query("SELECT * FROM games");
while( $row = mysql_fetch_array($result) ) {
echo "<a href=\"http://www.example.com/game/".$rw['Name']."\">";
}
Just looks a little cleaner, maybe :)
Thanks Chromate:)
Yeh and I agree about the Syntax, I usally get at least three parse errors when checking:)
Anyway, thanks a lot...
Mike
chromate
11-18-2003, 12:02 PM
Tell me about it. The reason I pointed it out is that I'm terrible myself, though much better than I was! I've spent ages getting really frustrated before because I couldn't find an error and then after about an hour, I find I've neglected to put in a quotation mark or something equally dumb! :) Bloody annoying if you have a deadline! haha
lol yeah
i made this script a few weeks ago, uploaded it to my host and decided not to save it as i thought it would be safe. anyway, it wasn't and it somehow got deleted.
so i tried to make it all again (only short). so i did it, uploaded it and got this ugly error (not saying what was missing). it pointed me to a line that had nothing wrong with it. anyway, after about an hour of fiddling about i finally found out that there was a missing quotation. grrr;)
why they can't make some sort of editor that corrects these mistakes...:)
chromate
11-18-2003, 12:29 PM
Originally posted by Mike
why they can't make some sort of editor that corrects these mistakes...:)
They do on a basic level. But in my experience they're more trouble than they're worth. It's best just to get into good practice to start with. Having said that, I started programming in Java which isn't very forgiving.
Now, what really annoys me as far as errors are concerned is Perl CGI. GRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRR RRRRRRRRRRRRRrrrrrrrrrrrrrrrrrr :)
Chris
11-18-2003, 03:25 PM
$REQUEST_URI is a variable that represents the requested file path after the domain.
Thanks:)
I will try it out later...
Well it kinda works, links ok and everything, but doesn't display the content. My code looks like:
$var_array = explode("/",$REQUEST_URI);
$var = $var_array[1];
//query
$result = mysql_query("SELECT * FROM games WHERE Name='$var'", $connect);
//echo title and game
$row = mysql_fetch_assoc($result);
//title
echo ("<head><title>");
echo "Games2Go.co.uk - ";
echo $row['Name'];
echo ("</title></head>");
echo $row['Name'];
echo ("<br><br>");
echo $row['Code'];
Haven't really got a clue whats wrong, any help please?
Thanks a lot,
Mike
Chris
11-19-2003, 10:14 AM
try echoing out $var to make sure you have the correct variable.
I had the wrong variable. It was set as '$var = $var_array[1]; ' when it should have been '$var = $var_array[2]; '
Anyhow thanks for all your help:)
Powered by vBulletin® Version 4.2.2 Copyright © 2024 vBulletin Solutions, Inc. All rights reserved.