<?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: Using .htaccess to make search engine-friendly URLs &#8211; &#8220;There is no spoon&#8221;</title>
	<atom:link href="http://www.jmblog.com/2009/11/15/using-htaccess-to-make-search-engine-friendly-urls-there-is-no-spoon/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.jmblog.com/2009/11/15/using-htaccess-to-make-search-engine-friendly-urls-there-is-no-spoon/</link>
	<description>the web journal of Jere Matlock. Observations on Website Design, SEO and much more....</description>
	<lastBuildDate>Mon, 12 Dec 2011 18:14:40 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=</generator>
<xhtml:meta xmlns:xhtml="http://www.w3.org/1999/xhtml" name="robots" content="noindex" />
	<item>
		<title>By: Jere Matlock</title>
		<link>http://www.jmblog.com/2009/11/15/using-htaccess-to-make-search-engine-friendly-urls-there-is-no-spoon/#comment-89758</link>
		<dc:creator>Jere Matlock</dc:creator>
		<pubDate>Fri, 30 Sep 2011 07:03:17 +0000</pubDate>
		<guid isPermaLink="false">http://www.jmblog.com/?p=365#comment-89758</guid>
		<description>Hi, Archana - I have no idea how to do this in .net.  Not my area of expertise at all.  I would be very surprised if it is possible in .net.

Best of luck to you</description>
		<content:encoded><![CDATA[<p>Hi, Archana &#8211; I have no idea how to do this in .net.  Not my area of expertise at all.  I would be very surprised if it is possible in .net.</p>
<p>Best of luck to you</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Archana</title>
		<link>http://www.jmblog.com/2009/11/15/using-htaccess-to-make-search-engine-friendly-urls-there-is-no-spoon/#comment-89687</link>
		<dc:creator>Archana</dc:creator>
		<pubDate>Thu, 29 Sep 2011 12:48:55 +0000</pubDate>
		<guid isPermaLink="false">http://www.jmblog.com/?p=365#comment-89687</guid>
		<description>Hey,

I am working in .net ... Could you please help me how can I make the search engine friendly URLs without making HTML pages for them please
..IF you find any answer then please mail me at:

Archanazohns@gmail.com</description>
		<content:encoded><![CDATA[<p>Hey,</p>
<p>I am working in .net &#8230; Could you please help me how can I make the search engine friendly URLs without making HTML pages for them please<br />
..IF you find any answer then please mail me at:</p>
<p><a href="mailto:Archanazohns@gmail.com">Archanazohns@gmail.com</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jere Matlock</title>
		<link>http://www.jmblog.com/2009/11/15/using-htaccess-to-make-search-engine-friendly-urls-there-is-no-spoon/#comment-77714</link>
		<dc:creator>Jere Matlock</dc:creator>
		<pubDate>Wed, 30 Mar 2011 04:41:26 +0000</pubDate>
		<guid isPermaLink="false">http://www.jmblog.com/?p=365#comment-77714</guid>
		<description>Hi, Calvin -

Yes, we went that route, too.  We tried for a week to get our .htaccess file to do a lookup (which it is supposed to be able to do) but we could NOT get it to work on our server, despite involving Tier II tech support and calling in an outside &quot;expert&quot;.  Nothing doing!  So we had to regroup.  They say &quot;Necessity is the mother of invention&quot; but I think it is more like &quot;Necessity is the mother of circumvention&quot; in this case.

Best,

Jere</description>
		<content:encoded><![CDATA[<p>Hi, Calvin -</p>
<p>Yes, we went that route, too.  We tried for a week to get our .htaccess file to do a lookup (which it is supposed to be able to do) but we could NOT get it to work on our server, despite involving Tier II tech support and calling in an outside &#8220;expert&#8221;.  Nothing doing!  So we had to regroup.  They say &#8220;Necessity is the mother of invention&#8221; but I think it is more like &#8220;Necessity is the mother of circumvention&#8221; in this case.</p>
<p>Best,</p>
<p>Jere</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Calvin</title>
		<link>http://www.jmblog.com/2009/11/15/using-htaccess-to-make-search-engine-friendly-urls-there-is-no-spoon/#comment-77702</link>
		<dc:creator>Calvin</dc:creator>
		<pubDate>Tue, 29 Mar 2011 21:48:30 +0000</pubDate>
		<guid isPermaLink="false">http://www.jmblog.com/?p=365#comment-77702</guid>
		<description>KUDOS!!!

I have looked for how to do what you describe in your last comment for 3 weeks with no luck. I never though it would be as easy as routing through a PHP script! I was trying to figure out a way to get .htaccess to read a database ( hits forehead with palm ).

Thanks a lot!!</description>
		<content:encoded><![CDATA[<p>KUDOS!!!</p>
<p>I have looked for how to do what you describe in your last comment for 3 weeks with no luck. I never though it would be as easy as routing through a PHP script! I was trying to figure out a way to get .htaccess to read a database ( hits forehead with palm ).</p>
<p>Thanks a lot!!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: sarala</title>
		<link>http://www.jmblog.com/2009/11/15/using-htaccess-to-make-search-engine-friendly-urls-there-is-no-spoon/#comment-75072</link>
		<dc:creator>sarala</dc:creator>
		<pubDate>Tue, 15 Feb 2011 16:00:09 +0000</pubDate>
		<guid isPermaLink="false">http://www.jmblog.com/?p=365#comment-75072</guid>
		<description>this is really wonderful and good and clarity explanation about the ht access. thank you for sharing.
www.seoupdates-sarala.blogspot.com</description>
		<content:encoded><![CDATA[<p>this is really wonderful and good and clarity explanation about the ht access. thank you for sharing.<br />
<a href="http://www.seoupdates-sarala.blogspot.com" rel="nofollow">http://www.seoupdates-sarala.blogspot.com</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jere Matlock</title>
		<link>http://www.jmblog.com/2009/11/15/using-htaccess-to-make-search-engine-friendly-urls-there-is-no-spoon/#comment-69270</link>
		<dc:creator>Jere Matlock</dc:creator>
		<pubDate>Tue, 07 Dec 2010 22:57:14 +0000</pubDate>
		<guid isPermaLink="false">http://www.jmblog.com/?p=365#comment-69270</guid>
		<description>Hi, Eric -

If you need to set this up, you need someone to do it who knows what they are doing.  It&#039;s not for the faint of heart.

Here&#039;s an example:  We had a &quot;media. website. com&quot; sub-domain, which was being hosted on another server.  We consolidated hosting and moved all of the &quot;media&quot; content over to a blog, at &quot;blog. website. com&quot;

In the &quot;media&quot; folder, we put an .htaccess with this code in it:

&lt;code&gt;Options +FollowSymLinks

AddType text/html .html
AddType text/html .htm
AddType text/xml .xml

AddHandler server-parsed .html
AddHandler server-parsed .htm
AddHandler server-parsed .xml


RewriteEngine On

RewriteCond %{HTTP_HOST} ^media.website.com
RewriteCond %{REQUEST_URI} !^/dispatcher.php
RewriteRule (.*) /dispatcher.php?file=$1 [R=301,L,QSA]&lt;/code&gt;

That&#039;s what does the &quot;heavy lifting&quot; for us.

--------------------

Then we have in &quot;dispatcher.php&quot; the following code to pull apart the pieces of the URI being requested, and look for it in the little table in the database with the old and new page names in it, and then set the location.  The result is a clean shift from one URL to another, with a 301 code sent and the right URI being served for the request.  Note that this replaces about 400 lines of .htaccess file.
&lt;code&gt;
$request = $_SERVER[REQUEST_URI];
$request = trim($request);
$uriparts = explode(&#039;?&#039;, $request);
$vars = explode(&#039;&amp;&#039;, $uriparts);
if ($uriparts[1])
{
    parse_str($uriparts[1], $vars);
}

$file = array_shift($vars);
$var = array_shift($vars);
$pagevars = &quot;&quot;;

foreach ($var as $key =&gt; $value)
{
    $pagevars .= &quot;&amp;$key=$value&quot;;
}

$pagevars = str_replace(&quot; &quot;,&quot;+&quot;, $pagevars);
$pagevars = substr_replace($pagevars,&quot;&quot;, 0,1);

$query=&quot;SELECT * FROM redirs
        WHERE page = &#039;/$file&#039;
        AND qry = &#039;$pagevars&#039;
        LIMIT 1&quot;;
echo &quot;&lt;p&gt;Query = $query&lt;/p&gt;&quot;;
$result = mysql_query($query);
/*if (mysql_num_rows($result) == 1)
{
    $row = mysql_fetch_array($result);
    $redirect = &quot;http : // blog .thiswebsite .com&quot; . $row[direct];

    header(&quot;Location: $redirect&quot;);
}
else {

     header(&quot;Location: http : / /blog. thiswebsite. com/default-page.php&quot;);
} */&lt;/code&gt;</description>
		<content:encoded><![CDATA[<p>Hi, Eric -</p>
<p>If you need to set this up, you need someone to do it who knows what they are doing.  It&#8217;s not for the faint of heart.</p>
<p>Here&#8217;s an example:  We had a &#8220;media. website. com&#8221; sub-domain, which was being hosted on another server.  We consolidated hosting and moved all of the &#8220;media&#8221; content over to a blog, at &#8220;blog. website. com&#8221;</p>
<p>In the &#8220;media&#8221; folder, we put an .htaccess with this code in it:</p>
<p><code>Options +FollowSymLinks</p>
<p>AddType text/html .html<br />
AddType text/html .htm<br />
AddType text/xml .xml</p>
<p>AddHandler server-parsed .html<br />
AddHandler server-parsed .htm<br />
AddHandler server-parsed .xml</p>
<p>RewriteEngine On</p>
<p>RewriteCond %{HTTP_HOST} ^media.website.com<br />
RewriteCond %{REQUEST_URI} !^/dispatcher.php<br />
RewriteRule (.*) /dispatcher.php?file=$1 [R=301,L,QSA]</code></p>
<p>That&#8217;s what does the &#8220;heavy lifting&#8221; for us.</p>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;</p>
<p>Then we have in &#8220;dispatcher.php&#8221; the following code to pull apart the pieces of the URI being requested, and look for it in the little table in the database with the old and new page names in it, and then set the location.  The result is a clean shift from one URL to another, with a 301 code sent and the right URI being served for the request.  Note that this replaces about 400 lines of .htaccess file.<br />
<code><br />
$request = $_SERVER[REQUEST_URI];<br />
$request = trim($request);<br />
$uriparts = explode('?', $request);<br />
$vars = explode('&#038;', $uriparts);<br />
if ($uriparts[1])<br />
{<br />
    parse_str($uriparts[1], $vars);<br />
}</p>
<p>$file = array_shift($vars);<br />
$var = array_shift($vars);<br />
$pagevars = "";</p>
<p>foreach ($var as $key => $value)<br />
{<br />
    $pagevars .= "&#038;$key=$value";<br />
}</p>
<p>$pagevars = str_replace(" ","+", $pagevars);<br />
$pagevars = substr_replace($pagevars,"", 0,1);</p>
<p>$query="SELECT * FROM redirs<br />
        WHERE page = '/$file'<br />
        AND qry = '$pagevars'<br />
        LIMIT 1";<br />
echo "
<p>Query = $query</p>
<p>";<br />
$result = mysql_query($query);<br />
/*if (mysql_num_rows($result) == 1)<br />
{<br />
    $row = mysql_fetch_array($result);<br />
    $redirect = "http : // blog .thiswebsite .com" . $row[direct];</p>
<p>    header("Location: $redirect");<br />
}<br />
else {</p>
<p>     header("Location: http : / /blog. thiswebsite. com/default-page.php");<br />
} */</code></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Eric</title>
		<link>http://www.jmblog.com/2009/11/15/using-htaccess-to-make-search-engine-friendly-urls-there-is-no-spoon/#comment-69230</link>
		<dc:creator>Eric</dc:creator>
		<pubDate>Tue, 07 Dec 2010 08:18:42 +0000</pubDate>
		<guid isPermaLink="false">http://www.jmblog.com/?p=365#comment-69230</guid>
		<description>could you please give a code sample for dispatcher and htaccess as ho how this is implemented?</description>
		<content:encoded><![CDATA[<p>could you please give a code sample for dispatcher and htaccess as ho how this is implemented?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jere Matlock</title>
		<link>http://www.jmblog.com/2009/11/15/using-htaccess-to-make-search-engine-friendly-urls-there-is-no-spoon/#comment-68964</link>
		<dc:creator>Jere Matlock</dc:creator>
		<pubDate>Tue, 30 Nov 2010 18:44:16 +0000</pubDate>
		<guid isPermaLink="false">http://www.jmblog.com/?p=365#comment-68964</guid>
		<description>Hi, Abbas -

No, you don&#039;t have to do this by hand for each entry.

When you have a very large, very active database-driven site, it is best to set up something we have given the name of &quot;dispatcher&quot;.

Basically, you route the traffic through to a php file called dispatcher.php, that does a lookup in a mySQL database and provides the appropriate name.

We just did this for a big media room (call it media.website.com) with several thousand pages, which we routed over to a blog (blog.website.com).  Most of the pages of the media room were moved, but not all of them.  Requests for those pages that were not moved are served a generic page with a 301 code.  Requests for pages that were moved are given a 301 redirect to the exact page name in the blog that we want to serve up instead.

To give credit where it is due, we &quot;lifted&quot; this system from the xCart shopping cart, which uses a file called &quot;dispatcher.php&quot; to do exactly the same thing.  That&#039;s how it makes search-engine-friendly URLs.

Dispatcher.php, when called by the htaccess file, becomes part of the process of determining the page name to be displayed.  The .htaccess file sends all traffic to it, it does a lookup in the database, finds the right file name, and sets the &quot;location&quot;.  It&#039;s much, much faster than trying to do all this redirection through the .htaccess file.

So the thing to do is make a search-engine-friendly URL for any page that you create (even if it is done automatically) and store that in a database table, then use the dispatcher.php file to go get that file name and serve it up instead of the funky variable-filled URL that is not friendly to the search engines.

If you need more help on this, we would be happy to consult with you on it.  &lt;a href=&quot;http://www.jmblog.com/contact/&quot; rel=&quot;nofollow&quot;&gt;Contact me&lt;/a&gt; directly for a free initial consultation.</description>
		<content:encoded><![CDATA[<p>Hi, Abbas -</p>
<p>No, you don&#8217;t have to do this by hand for each entry.</p>
<p>When you have a very large, very active database-driven site, it is best to set up something we have given the name of &#8220;dispatcher&#8221;.</p>
<p>Basically, you route the traffic through to a php file called dispatcher.php, that does a lookup in a mySQL database and provides the appropriate name.</p>
<p>We just did this for a big media room (call it media.website.com) with several thousand pages, which we routed over to a blog (blog.website.com).  Most of the pages of the media room were moved, but not all of them.  Requests for those pages that were not moved are served a generic page with a 301 code.  Requests for pages that were moved are given a 301 redirect to the exact page name in the blog that we want to serve up instead.</p>
<p>To give credit where it is due, we &#8220;lifted&#8221; this system from the xCart shopping cart, which uses a file called &#8220;dispatcher.php&#8221; to do exactly the same thing.  That&#8217;s how it makes search-engine-friendly URLs.</p>
<p>Dispatcher.php, when called by the htaccess file, becomes part of the process of determining the page name to be displayed.  The .htaccess file sends all traffic to it, it does a lookup in the database, finds the right file name, and sets the &#8220;location&#8221;.  It&#8217;s much, much faster than trying to do all this redirection through the .htaccess file.</p>
<p>So the thing to do is make a search-engine-friendly URL for any page that you create (even if it is done automatically) and store that in a database table, then use the dispatcher.php file to go get that file name and serve it up instead of the funky variable-filled URL that is not friendly to the search engines.</p>
<p>If you need more help on this, we would be happy to consult with you on it.  <a href="http://www.jmblog.com/contact/" rel="nofollow">Contact me</a> directly for a free initial consultation.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Eric</title>
		<link>http://www.jmblog.com/2009/11/15/using-htaccess-to-make-search-engine-friendly-urls-there-is-no-spoon/#comment-68960</link>
		<dc:creator>Eric</dc:creator>
		<pubDate>Tue, 30 Nov 2010 16:54:53 +0000</pubDate>
		<guid isPermaLink="false">http://www.jmblog.com/?p=365#comment-68960</guid>
		<description>Hi 

Great tut, but all the time I&#039;m reading your post and Q&amp;A I have a question I still am very keen to confirm.. lets take the following case for example;
--------------------------------------
Hi, Abbas -

Test this code in your .htaccess file, to see if it works:

RewriteEngine On
RewriteRule ^detail-433.htm /detail.php?siteid=433 [L]
--------------------------------------
so the above solution is just for id number 433... does that mean we have to do this for every id 1 to 433? And what about the future where it is quite possible for ids to go up all the way to thousands.. and what if the website gets 10 new ids an hour, do we manually create a mod rewrite for each new id? Wouldn&#039;t that take just take up all of our time?</description>
		<content:encoded><![CDATA[<p>Hi </p>
<p>Great tut, but all the time I&#8217;m reading your post and Q&amp;A I have a question I still am very keen to confirm.. lets take the following case for example;<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
Hi, Abbas -</p>
<p>Test this code in your .htaccess file, to see if it works:</p>
<p>RewriteEngine On<br />
RewriteRule ^detail-433.htm /detail.php?siteid=433 [L]<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
so the above solution is just for id number 433&#8230; does that mean we have to do this for every id 1 to 433? And what about the future where it is quite possible for ids to go up all the way to thousands.. and what if the website gets 10 new ids an hour, do we manually create a mod rewrite for each new id? Wouldn&#8217;t that take just take up all of our time?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jere Matlock</title>
		<link>http://www.jmblog.com/2009/11/15/using-htaccess-to-make-search-engine-friendly-urls-there-is-no-spoon/#comment-65568</link>
		<dc:creator>Jere Matlock</dc:creator>
		<pubDate>Wed, 27 Oct 2010 17:41:19 +0000</pubDate>
		<guid isPermaLink="false">http://www.jmblog.com/?p=365#comment-65568</guid>
		<description>Hi, Jim -

I&#039;ve run into this before.

Try setting the &quot;base&quot; HTML command within cat.php.

Or try setting up a Rewrite Rule that sends the &quot;include&quot; request to the correct folder.

Note: You can have multiple .htaccess files within the different folders on your server at different levels on the server.

Best,

Jere Matlock</description>
		<content:encoded><![CDATA[<p>Hi, Jim -</p>
<p>I&#8217;ve run into this before.</p>
<p>Try setting the &#8220;base&#8221; HTML command within cat.php.</p>
<p>Or try setting up a Rewrite Rule that sends the &#8220;include&#8221; request to the correct folder.</p>
<p>Note: You can have multiple .htaccess files within the different folders on your server at different levels on the server.</p>
<p>Best,</p>
<p>Jere Matlock</p>
]]></content:encoded>
	</item>
</channel>
</rss>

