<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	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/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Web Design Talk &#187; XAMPP</title>
	<atom:link href="http://www.web-design-talk.co.uk/category/xampp/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.web-design-talk.co.uk</link>
	<description>Web Design &#38; Development Blog</description>
	<lastBuildDate>Wed, 28 Jul 2010 21:50:39 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Detect AJAX Requests using the x-requested-with header and xmlhttprequest</title>
		<link>http://www.web-design-talk.co.uk/197/detect-ajax-requests-using-the-x-requested-with-header-and-xmlhttprequest/</link>
		<comments>http://www.web-design-talk.co.uk/197/detect-ajax-requests-using-the-x-requested-with-header-and-xmlhttprequest/#comments</comments>
		<pubDate>Thu, 25 Mar 2010 15:32:47 +0000</pubDate>
		<dc:creator>Rob</dc:creator>
				<category><![CDATA[Ajax]]></category>
		<category><![CDATA[General]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[XAMPP]]></category>

		<guid isPermaLink="false">http://www.web-design-talk.co.uk/?p=197</guid>
		<description><![CDATA[This is a small snippet of code I came across today, it allows a script to display different content based on how it was requested. This method allows your scripts to remain in a single file, handing both AJAX and normal requests &#8211; it avoids ending up with lots of small PHP files in your [...]]]></description>
			<content:encoded><![CDATA[<p>This is a small snippet of code I came across today, it allows a script to display different content based on how it was requested. This method allows your scripts to remain in a single file, handing both AJAX and normal requests &#8211; it avoids ending up with lots of small PHP files in your AJAX folder, that deals with <strong>ajax requests</strong>.Another use would be a page that has 2 web forms, one AJAX and one normal. You could keep the code for this page in a single file. This method is also useful for security purposes, as it would ensure that requests to your AJAX scripts are via AJAX only. It also has uses for writing unobtrusive JavaScript &#8211; maybe ensuring that an AJAX enabled web form would work when javascript is disbaled.</p>
<p>For example, the below code would display different code depending on if the request for the page was made via AJAX or directly via a browser.</p>
<pre class="brush: php;">
if(isset($_SERVER['HTTP_X_REQUESTED_WITH']) &amp;&amp; strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest') {
    //This is an AJAX request, do AJAX specific stuff
}
else {
    //This is not an AJAX request E.g. display normal page content.
}
</pre>
<p>In some code I was working on today, I saw a neater way of achieving the above, this would be included in your common config file:</p>
<pre class="brush: php;">
define('IS_AJAX_REQUEST', isset($_SERVER['HTTP_X_REQUESTED_WITH']) &amp;&amp; strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest');

if(IS_AJAX_REQUEST) {
    //This is an AJAX request, do AJAX specific stuff
}
else {
    //This is not an AJAX request E.g. display normal page content.
}
</pre>
<p>There&#8217;s an HTTP variable set called <strong>HTTP_X_REQUESTED_WITH</strong>, which will is set to &#8216;<strong>XMLHttpRequest</strong>&#8216; if the request method is via AJAX. This is method is untested with JavaScript frameworks other than JQuery, so may not work (but I don&#8217;t see any reason at all why it wouldn&#8217;t!).</p>
<p>It&#8217;s also worth noting that not all web servers include this variable and sometimes omit this specific $_SERVER paramter. Use vardump($_SERVER) to check that the <strong>HTTP_X_REQUESTED_WITH</strong> is present.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.web-design-talk.co.uk/197/detect-ajax-requests-using-the-x-requested-with-header-and-xmlhttprequest/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Getting htaccess Mod-rewrite rules working locally with XAMPP</title>
		<link>http://www.web-design-talk.co.uk/126/getting-htaccess-mod-rewrite-working-locally-with-xampp/</link>
		<comments>http://www.web-design-talk.co.uk/126/getting-htaccess-mod-rewrite-working-locally-with-xampp/#comments</comments>
		<pubDate>Tue, 15 Sep 2009 00:28:46 +0000</pubDate>
		<dc:creator>Rob</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[LAMP]]></category>
		<category><![CDATA[XAMPP]]></category>
		<category><![CDATA[htaccess file]]></category>
		<category><![CDATA[relative path]]></category>
		<category><![CDATA[rewrite rule]]></category>

		<guid isPermaLink="false">http://www.web-design-talk.co.uk/?p=126</guid>
		<description><![CDATA[After spending a whole 2 hours of my life trying to get Apache mod-rewrite rules working with XAMPP on a local computer, I thought I&#8217;d share my results as I seemingly tried everything. The problem, I have a simple mod-rewrite rule in my htaccess file. When I upload this to my online web host everything [...]]]></description>
			<content:encoded><![CDATA[<p>After spending a whole 2 hours of my life trying to get Apache mod-rewrite rules working with <a href="http://www.apachefriends.org/en/xampp.html" target="_blank">XAMPP</a> on a local computer, I thought I&#8217;d share my results as I seemingly tried everything. The problem, I have a simple mod-rewrite rule in my htaccess file. When I upload this to my online web host everything is fine &#8211; the working htaccess file  for my online host:</p>
<pre class="brush: jscript;">
RewriteBase /
RewriteEngine on
RewriteRule amnesia/resetpass(.*) recover-password.php$1 [PT]
</pre>
<p>So typing in <code>www.domain.com/amnesia/resetpass</code> does a simple re-write to <code>www.domain.com/recover-password.php</code>, without the user ever knowing. All is fine. However, when I treid to get this seemingly simple rule to work with XAMPP I ran into problems, getting 404 and 500 responses from the server &#8211; obviously quite a pain as this essentially means I can&#8217;t test the site using my own web server (E.g. localhost). The site hosted from my computer via the normal setup E.g. xampp/htdocs/mysite. I&#8217;ll jump straight to the solution and then explain exactly what things were changed &#8211; the working htaccess file is below:</p>
<pre class="brush: jscript;">
RewriteEngine on
RewriteBase /mysite
options +FollowSymLinks
RewriteRule amnesia/resetpass(.*) recover-password.php$1 [PT]
</pre>
<p>Firstly, the extra line that uses the <code>+FollowSymLinks</code> directive was added. To explain this I&#8217;ll quote straught from the <a href="http://httpd.apache.org/docs/2.0/mod/mod_rewrite.html" target="_blank">Apache documentation</a>:</p>
<blockquote><p>To enable the rewriting engine           for per-directory configuration files, you need to set           &#8220;<code>RewriteEngine On</code>&#8221; in these files           <strong>and</strong> &#8220;<code>Options           FollowSymLinks</code>&#8221; must be enabled. If your           administrator has disabled override of           <code>FollowSymLinks</code> for a user&#8217;s directory, then           you cannot use the rewriting engine. This restriction is           needed for security reasons.</p></blockquote>
<p>The re-write base has been changed to the relative path of the website directory. To finish up, open the http.conf file (the default settings for XAMPP, that get overwritten with you .htaccess file rules on a directory basis), located by default at C:\xampp\apache\conf\http.conf. Find all occurances of <code>AllowOverride None</code> and change it to <code>AllowOverride All</code>. After restarting XAMPP everythign should work. In a nutshell changing the AllowOverride directive in the http.conf file decalres which directives in .htaccess files can override directives from httpd.conf, this is <a href="http://vr-zone.com/manual/en/mod/core.html#allowoverride" target="_self">discussed in more dept over here</a>, but basically by having this directive set to None, you&#8217;re stopping individual htaccess files from working locally.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.web-design-talk.co.uk/126/getting-htaccess-mod-rewrite-working-locally-with-xampp/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
