<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Creating clean URIs with PHP</title>
	<atom:link href="http://tiffanybbrown.com/2003/12/22/creating_clean_uris_with_php/feed/" rel="self" type="application/rss+xml" />
	<link>http://tiffanybbrown.com/2003/12/22/creating_clean_uris_with_php/</link>
	<description>A web log about web development and internet culture with frequent detours into other stuff.</description>
	<lastBuildDate>Fri, 03 Feb 2012 12:47:00 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
	<item>
		<title>By: Christopher</title>
		<link>http://tiffanybbrown.com/2003/12/22/creating_clean_uris_with_php/comment-page-1/#comment-90795</link>
		<dc:creator>Christopher</dc:creator>
		<pubDate>Fri, 11 Apr 2008 06:26:53 +0000</pubDate>
		<guid isPermaLink="false">http://tiffanybbrown.com/2003/12/22/creating_clean_uris_with_php#comment-90795</guid>
		<description>I would like to come here again. It sounds god to me, and there’s a lot of interesting information here</description>
		<content:encoded><![CDATA[<p>I would like to come here again. It sounds god to me, and there’s a lot of interesting information here</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Christopher</title>
		<link>http://tiffanybbrown.com/2003/12/22/creating_clean_uris_with_php/comment-page-1/#comment-92234</link>
		<dc:creator>Christopher</dc:creator>
		<pubDate>Fri, 11 Apr 2008 06:26:00 +0000</pubDate>
		<guid isPermaLink="false">http://tiffanybbrown.com/2003/12/22/creating_clean_uris_with_php#comment-92234</guid>
		<description>I would like to come here again. It sounds god to me, and there’s a lot of interesting information here</description>
		<content:encoded><![CDATA[<p>I would like to come here again. It sounds god to me, and there’s a lot of interesting information here</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Rewt</title>
		<link>http://tiffanybbrown.com/2003/12/22/creating_clean_uris_with_php/comment-page-1/#comment-85391</link>
		<dc:creator>Rewt</dc:creator>
		<pubDate>Thu, 02 Aug 2007 10:45:48 +0000</pubDate>
		<guid isPermaLink="false">http://tiffanybbrown.com/2003/12/22/creating_clean_uris_with_php#comment-85391</guid>
		<description>Instead of fooling with mod_rewrite, just use .htaccess:

ErrorDocument 404 /index.php

Then, in your index.php file:

$request = explode(&#039;/&#039;, $_SERVER[&#039;REQUEST_URI&#039;]);
array_shift($request);

Now any file name (like index.php or example.com/newsletter) becomes $request[0]... since we&#039;re exploding the slash, you can do:

www.example.com/articles/how-to/build-friendly-uri

Since Apache won&#039;t find that URL, it defaults to index.php, which then breaks it up.

$request[0] = articles
$request[1] = how-to
$request[2] = build-friendly-uri

At this point, you can pass variables to mySQL, or do whatever you want with them. Pretty easy.

You can see by using the ErrorDocument directive, you can just easily create these.

Andy</description>
		<content:encoded><![CDATA[<p>Instead of fooling with mod_rewrite, just use .htaccess:</p>
<p>ErrorDocument 404 /index.php</p>
<p>Then, in your index.php file:</p>
<p>$request = explode(&#8216;/&#8217;, $_SERVER['REQUEST_URI']);<br />
array_shift($request);</p>
<p>Now any file name (like index.php or example.com/newsletter) becomes $request[0]&#8230; since we&#8217;re exploding the slash, you can do:</p>
<p><a href="http://www.example.com/articles/how-to/build-friendly-uri" rel="nofollow">http://www.example.com/articles/how-to/build-friendly-uri</a></p>
<p>Since Apache won&#8217;t find that URL, it defaults to index.php, which then breaks it up.</p>
<p>$request[0] = articles<br />
$request[1] = how-to<br />
$request[2] = build-friendly-uri</p>
<p>At this point, you can pass variables to mySQL, or do whatever you want with them. Pretty easy.</p>
<p>You can see by using the ErrorDocument directive, you can just easily create these.</p>
<p>Andy</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Rewt</title>
		<link>http://tiffanybbrown.com/2003/12/22/creating_clean_uris_with_php/comment-page-1/#comment-92233</link>
		<dc:creator>Rewt</dc:creator>
		<pubDate>Thu, 02 Aug 2007 10:45:00 +0000</pubDate>
		<guid isPermaLink="false">http://tiffanybbrown.com/2003/12/22/creating_clean_uris_with_php#comment-92233</guid>
		<description>Instead of fooling with mod_rewrite, just use .htaccess:

ErrorDocument 404 /index.php

Then, in your index.php file:

$request = explode(&#039;/&#039;, $_SERVER[&#039;REQUEST_URI&#039;]);
array_shift($request);

Now any file name (like index.php or example.com/newsletter) becomes $request[0]... since we&#039;re exploding the slash, you can do:

www.example.com/articles/how-to/build-friendly-uri

Since Apache won&#039;t find that URL, it defaults to index.php, which then breaks it up.

$request[0] = articles
$request[1] = how-to
$request[2] = build-friendly-uri

At this point, you can pass variables to mySQL, or do whatever you want with them. Pretty easy.

You can see by using the ErrorDocument directive, you can just easily create these.

Andy</description>
		<content:encoded><![CDATA[<p>Instead of fooling with mod_rewrite, just use .htaccess:</p>
<p>ErrorDocument 404 /index.php</p>
<p>Then, in your index.php file:</p>
<p>$request = explode(&#8216;/&#8217;, $_SERVER['REQUEST_URI']);<br />
array_shift($request);</p>
<p>Now any file name (like index.php or example.com/newsletter) becomes $request[0]&#8230; since we&#8217;re exploding the slash, you can do:</p>
<p><a href="http://www.example.com/articles/how-to/build-friendly-uri" rel="nofollow">http://www.example.com/articles/how-to/build-friendly-uri</a></p>
<p>Since Apache won&#8217;t find that URL, it defaults to index.php, which then breaks it up.</p>
<p>$request[0] = articles<br />
$request[1] = how-to<br />
$request[2] = build-friendly-uri</p>
<p>At this point, you can pass variables to mySQL, or do whatever you want with them. Pretty easy.</p>
<p>You can see by using the ErrorDocument directive, you can just easily create these.</p>
<p>Andy</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: tiffany</title>
		<link>http://tiffanybbrown.com/2003/12/22/creating_clean_uris_with_php/comment-page-1/#comment-71823</link>
		<dc:creator>tiffany</dc:creator>
		<pubDate>Tue, 29 May 2007 17:27:29 +0000</pubDate>
		<guid isPermaLink="false">http://tiffanybbrown.com/2003/12/22/creating_clean_uris_with_php#comment-71823</guid>
		<description>Hey Nicolas,

I&#039;m not sure I understand what you&#039;re trying to do with a page title. It should just be a matter of escaping the page with htmlentities(), or using str_replace() to replace the offending characters.

&quot;Also, when you say â€œa simple SELECT properly escaped to avoid SQL injectionâ€?, what do you mean?&quot;

If you are accepting user input, you want to make sure that the user hasn&#039;t inserted some nasty command or poor syntax that could give you bad data -- or worse, destroy your database.

One way to do this is to use mysql_real_escape_string($varName) around your variables. 

Another way is to check that the value you receive is the same type as the one you were expecting. Say, for example, your SQL query is &quot;SELECT * FROM posts WHERE id=$_GET[&#039;id&#039;].&quot; In that case, you definitely want to check whether or not $_GET[&#039;id&#039;] is a numeric string using either &lt;a href=&quot;http://tiffanybbrown.com/2006/07/27/php-quickie-is_numeric-versus-ctype_digit&quot; rel=&quot;nofollow&quot;&gt;is_numeric() or ctype_digit()&lt;/a&gt;.</description>
		<content:encoded><![CDATA[<p>Hey Nicolas,</p>
<p>I&#8217;m not sure I understand what you&#8217;re trying to do with a page title. It should just be a matter of escaping the page with htmlentities(), or using str_replace() to replace the offending characters.</p>
<p>&#8220;Also, when you say â€œa simple SELECT properly escaped to avoid SQL injectionâ€?, what do you mean?&#8221;</p>
<p>If you are accepting user input, you want to make sure that the user hasn&#8217;t inserted some nasty command or poor syntax that could give you bad data &#8212; or worse, destroy your database.</p>
<p>One way to do this is to use mysql_real_escape_string($varName) around your variables. </p>
<p>Another way is to check that the value you receive is the same type as the one you were expecting. Say, for example, your SQL query is &#8220;SELECT * FROM posts WHERE id=$_GET['id'].&#8221; In that case, you definitely want to check whether or not $_GET['id'] is a numeric string using either <a href="http://tiffanybbrown.com/2006/07/27/php-quickie-is_numeric-versus-ctype_digit" rel="nofollow">is_numeric() or ctype_digit()</a>.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: tiffany</title>
		<link>http://tiffanybbrown.com/2003/12/22/creating_clean_uris_with_php/comment-page-1/#comment-92232</link>
		<dc:creator>tiffany</dc:creator>
		<pubDate>Tue, 29 May 2007 17:27:00 +0000</pubDate>
		<guid isPermaLink="false">http://tiffanybbrown.com/2003/12/22/creating_clean_uris_with_php#comment-92232</guid>
		<description>Hey Nicolas,

I&#039;m not sure I understand what you&#039;re trying to do with a page title. It should just be a matter of escaping the page with htmlentities(), or using str_replace() to replace the offending characters.

&quot;Also, when you say â€œa simple SELECT properly escaped to avoid SQL injectionâ€?, what do you mean?&quot;

If you are accepting user input, you want to make sure that the user hasn&#039;t inserted some nasty command or poor syntax that could give you bad data -- or worse, destroy your database.

One way to do this is to use mysql_real_escape_string($varName) around your variables. 

Another way is to check that the value you receive is the same type as the one you were expecting. Say, for example, your SQL query is &quot;SELECT * FROM posts WHERE id=$_GET[&#039;id&#039;].&quot; In that case, you definitely want to check whether or not $_GET[&#039;id&#039;] is a numeric string using either &lt;a href=&quot;http://tiffanybbrown.com/2006/07/27/php-quickie-is_numeric-versus-ctype_digit&quot; rel=&quot;nofollow&quot;&gt;is_numeric() or ctype_digit()&lt;/a&gt;.</description>
		<content:encoded><![CDATA[<p>Hey Nicolas,</p>
<p>I&#8217;m not sure I understand what you&#8217;re trying to do with a page title. It should just be a matter of escaping the page with htmlentities(), or using str_replace() to replace the offending characters.</p>
<p>&#8220;Also, when you say â€œa simple SELECT properly escaped to avoid SQL injectionâ€?, what do you mean?&#8221;</p>
<p>If you are accepting user input, you want to make sure that the user hasn&#8217;t inserted some nasty command or poor syntax that could give you bad data &#8212; or worse, destroy your database.</p>
<p>One way to do this is to use mysql_real_escape_string($varName) around your variables. </p>
<p>Another way is to check that the value you receive is the same type as the one you were expecting. Say, for example, your SQL query is &#8220;SELECT * FROM posts WHERE id=$_GET['id'].&#8221; In that case, you definitely want to check whether or not $_GET['id'] is a numeric string using either <a href="http://tiffanybbrown.com/2006/07/27/php-quickie-is_numeric-versus-ctype_digit" rel="nofollow">is_numeric() or ctype_digit()</a>.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Nicolas</title>
		<link>http://tiffanybbrown.com/2003/12/22/creating_clean_uris_with_php/comment-page-1/#comment-71819</link>
		<dc:creator>Nicolas</dc:creator>
		<pubDate>Tue, 29 May 2007 17:00:04 +0000</pubDate>
		<guid isPermaLink="false">http://tiffanybbrown.com/2003/12/22/creating_clean_uris_with_php#comment-71819</guid>
		<description>Hey Tiffany: 

Could you add an example of how to do this with the page title instead? i.e.: this one! (http://tiffanybbrown.com/2003/12/22/creating_clean_uris_with_php)
Also, when you say &quot;a simple SELECT properly escaped to avoid SQL injection&quot;, what do you mean?
thanks a lot.</description>
		<content:encoded><![CDATA[<p>Hey Tiffany: </p>
<p>Could you add an example of how to do this with the page title instead? i.e.: this one! (<a href="http://tiffanybbrown.com/2003/12/22/creating_clean_uris_with_php" rel="nofollow">http://tiffanybbrown.com/2003/12/22/creating_clean_uris_with_php</a>)<br />
Also, when you say &#8220;a simple SELECT properly escaped to avoid SQL injection&#8221;, what do you mean?<br />
thanks a lot.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Nicolas</title>
		<link>http://tiffanybbrown.com/2003/12/22/creating_clean_uris_with_php/comment-page-1/#comment-92231</link>
		<dc:creator>Nicolas</dc:creator>
		<pubDate>Tue, 29 May 2007 17:00:00 +0000</pubDate>
		<guid isPermaLink="false">http://tiffanybbrown.com/2003/12/22/creating_clean_uris_with_php#comment-92231</guid>
		<description>Hey Tiffany: 

Could you add an example of how to do this with the page title instead? i.e.: this one! (http://tiffanybbrown.com/2003/12/22/creating_clean_uris_with_php)
Also, when you say &quot;a simple SELECT properly escaped to avoid SQL injection&quot;, what do you mean?
thanks a lot.</description>
		<content:encoded><![CDATA[<p>Hey Tiffany: </p>
<p>Could you add an example of how to do this with the page title instead? i.e.: this one! (<a href="http://tiffanybbrown.com/2003/12/22/creating_clean_uris_with_php" rel="nofollow">http://tiffanybbrown.com/2003/12/22/creating_clean_uris_with_php</a>)<br />
Also, when you say &#8220;a simple SELECT properly escaped to avoid SQL injection&#8221;, what do you mean?<br />
thanks a lot.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: tiffany</title>
		<link>http://tiffanybbrown.com/2003/12/22/creating_clean_uris_with_php/comment-page-1/#comment-3566</link>
		<dc:creator>tiffany</dc:creator>
		<pubDate>Sun, 24 Sep 2006 17:07:29 +0000</pubDate>
		<guid isPermaLink="false">http://tiffanybbrown.com/2003/12/22/creating_clean_uris_with_php#comment-3566</guid>
		<description>ah...i think i had this problem as well. if i remember correctly, this tutorial will only work with numbers.

if you want to do something like &#039;index.php/Error,&#039; you&#039;ll need to use mod_rewrite (on Apache server).</description>
		<content:encoded><![CDATA[<p>ah&#8230;i think i had this problem as well. if i remember correctly, this tutorial will only work with numbers.</p>
<p>if you want to do something like &#8216;index.php/Error,&#8217; you&#8217;ll need to use mod_rewrite (on Apache server).</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: tiffany</title>
		<link>http://tiffanybbrown.com/2003/12/22/creating_clean_uris_with_php/comment-page-1/#comment-92230</link>
		<dc:creator>tiffany</dc:creator>
		<pubDate>Sun, 24 Sep 2006 17:07:00 +0000</pubDate>
		<guid isPermaLink="false">http://tiffanybbrown.com/2003/12/22/creating_clean_uris_with_php#comment-92230</guid>
		<description>ah...i think i had this problem as well. if i remember correctly, this tutorial will only work with numbers.

if you want to do something like &#039;index.php/Error,&#039; you&#039;ll need to use mod_rewrite (on Apache server).</description>
		<content:encoded><![CDATA[<p>ah&#8230;i think i had this problem as well. if i remember correctly, this tutorial will only work with numbers.</p>
<p>if you want to do something like &#8216;index.php/Error,&#8217; you&#8217;ll need to use mod_rewrite (on Apache server).</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Brian</title>
		<link>http://tiffanybbrown.com/2003/12/22/creating_clean_uris_with_php/comment-page-1/#comment-3480</link>
		<dc:creator>Brian</dc:creator>
		<pubDate>Fri, 22 Sep 2006 19:36:16 +0000</pubDate>
		<guid isPermaLink="false">http://tiffanybbrown.com/2003/12/22/creating_clean_uris_with_php#comment-3480</guid>
		<description>thanks. i figured it out. but i am stuck on one issue. maybe you can help me with it... i am trying to send an error message from one page to the next using this method. the problem is when the receiving page gets the message, somehow the URL makes the page paths invalid. i now have to use all absolute paths instead of relative. is there a way around this?

example:
when the URL was www.index.php?error=Error everthing was fine.
when the URL is www.index.php/Error i have problems because the paths in my index.php think they&#039;re in a folder called &quot;Error&quot;.

i hope that makes sense. if you have any suggestions that would be great, if not, thanks anyway.</description>
		<content:encoded><![CDATA[<p>thanks. i figured it out. but i am stuck on one issue. maybe you can help me with it&#8230; i am trying to send an error message from one page to the next using this method. the problem is when the receiving page gets the message, somehow the URL makes the page paths invalid. i now have to use all absolute paths instead of relative. is there a way around this?</p>
<p>example:<br />
when the URL was <a href="http://www.index.php?error=Error" rel="nofollow">http://www.index.php?error=Error</a> everthing was fine.<br />
when the URL is <a href="http://www.index.php/Error" rel="nofollow">http://www.index.php/Error</a> i have problems because the paths in my index.php think they&#8217;re in a folder called &#8220;Error&#8221;.</p>
<p>i hope that makes sense. if you have any suggestions that would be great, if not, thanks anyway.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Brian</title>
		<link>http://tiffanybbrown.com/2003/12/22/creating_clean_uris_with_php/comment-page-1/#comment-92229</link>
		<dc:creator>Brian</dc:creator>
		<pubDate>Fri, 22 Sep 2006 19:36:00 +0000</pubDate>
		<guid isPermaLink="false">http://tiffanybbrown.com/2003/12/22/creating_clean_uris_with_php#comment-92229</guid>
		<description>thanks. i figured it out. but i am stuck on one issue. maybe you can help me with it... i am trying to send an error message from one page to the next using this method. the problem is when the receiving page gets the message, somehow the URL makes the page paths invalid. i now have to use all absolute paths instead of relative. is there a way around this?

example:
when the URL was www.index.php?error=Error everthing was fine.
when the URL is www.index.php/Error i have problems because the paths in my index.php think they&#039;re in a folder called &quot;Error&quot;.

i hope that makes sense. if you have any suggestions that would be great, if not, thanks anyway.</description>
		<content:encoded><![CDATA[<p>thanks. i figured it out. but i am stuck on one issue. maybe you can help me with it&#8230; i am trying to send an error message from one page to the next using this method. the problem is when the receiving page gets the message, somehow the URL makes the page paths invalid. i now have to use all absolute paths instead of relative. is there a way around this?</p>
<p>example:<br />
when the URL was <a href="http://www.index.php?error=Error" rel="nofollow">http://www.index.php?error=Error</a> everthing was fine.<br />
when the URL is <a href="http://www.index.php/Error" rel="nofollow">http://www.index.php/Error</a> i have problems because the paths in my index.php think they&#8217;re in a folder called &#8220;Error&#8221;.</p>
<p>i hope that makes sense. if you have any suggestions that would be great, if not, thanks anyway.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: tiffany</title>
		<link>http://tiffanybbrown.com/2003/12/22/creating_clean_uris_with_php/comment-page-1/#comment-3444</link>
		<dc:creator>tiffany</dc:creator>
		<pubDate>Fri, 22 Sep 2006 01:28:32 +0000</pubDate>
		<guid isPermaLink="false">http://tiffanybbrown.com/2003/12/22/creating_clean_uris_with_php#comment-3444</guid>
		<description>Brian, that is the code. Split the URL using explode and use $entry[1] in your SQL. 

A simple &quot;select * from posts where id=$entry[1],&quot; properly escaped of course.</description>
		<content:encoded><![CDATA[<p>Brian, that is the code. Split the URL using explode and use $entry[1] in your SQL. </p>
<p>A simple &#8220;select * from posts where id=$entry[1],&#8221; properly escaped of course.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: tiffany</title>
		<link>http://tiffanybbrown.com/2003/12/22/creating_clean_uris_with_php/comment-page-1/#comment-92228</link>
		<dc:creator>tiffany</dc:creator>
		<pubDate>Fri, 22 Sep 2006 01:28:00 +0000</pubDate>
		<guid isPermaLink="false">http://tiffanybbrown.com/2003/12/22/creating_clean_uris_with_php#comment-92228</guid>
		<description>Brian, that is the code. Split the URL using explode and use $entry[1] in your SQL. 

A simple &quot;select * from posts where id=$entry[1],&quot; properly escaped of course.</description>
		<content:encoded><![CDATA[<p>Brian, that is the code. Split the URL using explode and use $entry[1] in your SQL. </p>
<p>A simple &#8220;select * from posts where id=$entry[1],&#8221; properly escaped of course.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Brian</title>
		<link>http://tiffanybbrown.com/2003/12/22/creating_clean_uris_with_php/comment-page-1/#comment-3438</link>
		<dc:creator>Brian</dc:creator>
		<pubDate>Thu, 21 Sep 2006 23:47:46 +0000</pubDate>
		<guid isPermaLink="false">http://tiffanybbrown.com/2003/12/22/creating_clean_uris_with_php#comment-3438</guid>
		<description>Good tutotial. I wish you would actually show the code within the actual pages to better explain what you&#039;re doing and where the code needs to go.</description>
		<content:encoded><![CDATA[<p>Good tutotial. I wish you would actually show the code within the actual pages to better explain what you&#8217;re doing and where the code needs to go.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

