<?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: How To Find The Current URL In PHP</title>
	<atom:link href="http://www.learnphponline.com/php-basics/how-to-find-the-current-url-in-php/feed" rel="self" type="application/rss+xml" />
	<link>http://www.learnphponline.com/php-basics/how-to-find-the-current-url-in-php</link>
	<description>Learn PHP Online</description>
	<lastBuildDate>Fri, 23 Dec 2011 17:09:11 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3</generator>
	<item>
		<title>By: Er1c S</title>
		<link>http://www.learnphponline.com/php-basics/how-to-find-the-current-url-in-php/comment-page-1#comment-13483</link>
		<dc:creator>Er1c S</dc:creator>
		<pubDate>Tue, 04 Oct 2011 13:47:29 +0000</pubDate>
		<guid isPermaLink="false">http://www.learnphponline.com/?p=114#comment-13483</guid>
		<description>@ FC:
// How do I find out if someone came from a link with an anchor ...
if ( strpos( $_SERVER[&#039;REQUEST_URI&#039;], &#039;#some_anchor&#039;) &gt; 0) {
    // you came to #some_anchor
}</description>
		<content:encoded><![CDATA[<p>@ FC:<br />
// How do I find out if someone came from a link with an anchor &#8230;<br />
if ( strpos( $_SERVER['REQUEST_URI'], &#8216;#some_anchor&#8217;) &gt; 0) {<br />
    // you came to #some_anchor<br />
}</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: megainfo</title>
		<link>http://www.learnphponline.com/php-basics/how-to-find-the-current-url-in-php/comment-page-1#comment-13349</link>
		<dc:creator>megainfo</dc:creator>
		<pubDate>Sat, 24 Sep 2011 20:20:23 +0000</pubDate>
		<guid isPermaLink="false">http://www.learnphponline.com/?p=114#comment-13349</guid>
		<description>[CODE]
$canonicalUrl  = &quot;http://&quot; . $_SERVER[&#039;HTTP_HOST&#039;] . $_SERVER[&#039;SCRIPT_NAME&#039;] .&#039;?&#039; . $_SERVER[&#039;QUERY_STRING&#039;];

$canonical = &#039;&#039;;

[/CODE]</description>
		<content:encoded><![CDATA[<p>[CODE]<br />
$canonicalUrl  = &#8220;http://&#8221; . $_SERVER['HTTP_HOST'] . $_SERVER['SCRIPT_NAME'] .&#8217;?&#8217; . $_SERVER['QUERY_STRING'];</p>
<p>$canonical = &#8221;;</p>
<p>[/CODE]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: caroline I</title>
		<link>http://www.learnphponline.com/php-basics/how-to-find-the-current-url-in-php/comment-page-1#comment-13115</link>
		<dc:creator>caroline I</dc:creator>
		<pubDate>Mon, 05 Sep 2011 14:51:45 +0000</pubDate>
		<guid isPermaLink="false">http://www.learnphponline.com/?p=114#comment-13115</guid>
		<description>Thanks very much for this clear explanation.  I&#039;d also been looking for a while on how to simply get a site&#039;s url as I was redirecting a domain to another and needed the URL as a variable.</description>
		<content:encoded><![CDATA[<p>Thanks very much for this clear explanation.  I&#8217;d also been looking for a while on how to simply get a site&#8217;s url as I was redirecting a domain to another and needed the URL as a variable.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Leyton Jay</title>
		<link>http://www.learnphponline.com/php-basics/how-to-find-the-current-url-in-php/comment-page-1#comment-12790</link>
		<dc:creator>Leyton Jay</dc:creator>
		<pubDate>Tue, 16 Aug 2011 10:47:56 +0000</pubDate>
		<guid isPermaLink="false">http://www.learnphponline.com/?p=114#comment-12790</guid>
		<description>This is awesome sauce, cheers!</description>
		<content:encoded><![CDATA[<p>This is awesome sauce, cheers!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Nicholas Maietta</title>
		<link>http://www.learnphponline.com/php-basics/how-to-find-the-current-url-in-php/comment-page-1#comment-10589</link>
		<dc:creator>Nicholas Maietta</dc:creator>
		<pubDate>Wed, 13 Apr 2011 19:02:15 +0000</pubDate>
		<guid isPermaLink="false">http://www.learnphponline.com/?p=114#comment-10589</guid>
		<description>A note to anyone writing a script or piece of software that has to &quot;neutralize&quot; a web address for the purposes of matching against, lets say... a database to pull content... (Such as Commnetivity), you might want to consider that some of the environment variables change under certain circumstances. One of those circumstances would be on an web server (ie, apache) level redirect to serve up a page. A good example is that if direct all traffic to a script using .htaccess, including 403&#039;s (Directory Listing Denied for real directories), Then your normal methods of derriving the URL or URI stuff isn&#039;t going to work and can have you beating your head against the wall. (I have a flat head, i know).

My recommendation to anyone trying to build a CMS like i did, is simply to understand first how those Environment variables are derrived by the webserver and read the RFC standards that deal with this. Then, before analyzing the URL or URI, you should first use maybe a switch case scenario for determining the http response from the server. Then and only then you can figure out which methods would most likely work.

These sample document requests are simple, but they can show where bugs might be in your code for deriving a &quot;virtual path&quot; as i like to call it.

/normalpage.html
/                        &lt;- No page, just a fowardslash.
/?Something
/?Something=Stupid
/index.html?Test
/index.html?Test=Nothing
/index.?Test
/index.
/?
//
///
/../
/./
/somefakefolder/somerealfolder/somefile.html
/somerealfolder/somefakefolder/somefile.html
/somerealfolder/

etc.

My methods i cannot disclose, as i do have to feed myself, but after 10 years of website developement the oldschool ways, i finally made the crazy move to build a very lightweight but well thought out CMS. Derriving a clean URL for matching against references was a HUGE part of the solution.

Oh, just for fun, i had to make sure this worked on not just with Apache, but also with other servers... AND had to work with *nix and windows alike. (Mac OS X and higher is based off *nix, so dont think im a mac hater).

I have now given you a good nugget of information my friends, and i dont mind a little competition if any of you out there are really serious about building a power CMS. Over 2 years of hell to make it... and nearly homeless the whole time. Little food, no real transportation (a bike over 12 miles a day to get wifi to develop the software). I want people to understand that you dont want to build something unless you poor your heart into it (keeping in mind the security of the websites that run on your CMS).</description>
		<content:encoded><![CDATA[<p>A note to anyone writing a script or piece of software that has to &#8220;neutralize&#8221; a web address for the purposes of matching against, lets say&#8230; a database to pull content&#8230; (Such as Commnetivity), you might want to consider that some of the environment variables change under certain circumstances. One of those circumstances would be on an web server (ie, apache) level redirect to serve up a page. A good example is that if direct all traffic to a script using .htaccess, including 403&#8242;s (Directory Listing Denied for real directories), Then your normal methods of derriving the URL or URI stuff isn&#8217;t going to work and can have you beating your head against the wall. (I have a flat head, i know).</p>
<p>My recommendation to anyone trying to build a CMS like i did, is simply to understand first how those Environment variables are derrived by the webserver and read the RFC standards that deal with this. Then, before analyzing the URL or URI, you should first use maybe a switch case scenario for determining the http response from the server. Then and only then you can figure out which methods would most likely work.</p>
<p>These sample document requests are simple, but they can show where bugs might be in your code for deriving a &#8220;virtual path&#8221; as i like to call it.</p>
<p>/normalpage.html<br />
/                        &lt;- No page, just a fowardslash.<br />
/?Something<br />
/?Something=Stupid<br />
/index.html?Test<br />
/index.html?Test=Nothing<br />
/index.?Test<br />
/index.<br />
/?<br />
//<br />
///<br />
/../<br />
/./<br />
/somefakefolder/somerealfolder/somefile.html<br />
/somerealfolder/somefakefolder/somefile.html<br />
/somerealfolder/</p>
<p>etc.</p>
<p>My methods i cannot disclose, as i do have to feed myself, but after 10 years of website developement the oldschool ways, i finally made the crazy move to build a very lightweight but well thought out CMS. Derriving a clean URL for matching against references was a HUGE part of the solution.</p>
<p>Oh, just for fun, i had to make sure this worked on not just with Apache, but also with other servers&#8230; AND had to work with *nix and windows alike. (Mac OS X and higher is based off *nix, so dont think im a mac hater).</p>
<p>I have now given you a good nugget of information my friends, and i dont mind a little competition if any of you out there are really serious about building a power CMS. Over 2 years of hell to make it&#8230; and nearly homeless the whole time. Little food, no real transportation (a bike over 12 miles a day to get wifi to develop the software). I want people to understand that you dont want to build something unless you poor your heart into it (keeping in mind the security of the websites that run on your CMS).</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: FC</title>
		<link>http://www.learnphponline.com/php-basics/how-to-find-the-current-url-in-php/comment-page-1#comment-10048</link>
		<dc:creator>FC</dc:creator>
		<pubDate>Sat, 02 Apr 2011 06:37:14 +0000</pubDate>
		<guid isPermaLink="false">http://www.learnphponline.com/?p=114#comment-10048</guid>
		<description>What do you do if you want to find if an anchor tag was used. I want to see if someone came into the page

test.php vs test.php#some_anchor</description>
		<content:encoded><![CDATA[<p>What do you do if you want to find if an anchor tag was used. I want to see if someone came into the page</p>
<p>test.php vs test.php#some_anchor</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Aaron W</title>
		<link>http://www.learnphponline.com/php-basics/how-to-find-the-current-url-in-php/comment-page-1#comment-9321</link>
		<dc:creator>Aaron W</dc:creator>
		<pubDate>Sat, 19 Mar 2011 08:31:48 +0000</pubDate>
		<guid isPermaLink="false">http://www.learnphponline.com/?p=114#comment-9321</guid>
		<description>Just what I needed. This worked like a charm! I searched other places online for how to do this, but this was the simplest solution I found, and the best explanation. Thanks!</description>
		<content:encoded><![CDATA[<p>Just what I needed. This worked like a charm! I searched other places online for how to do this, but this was the simplest solution I found, and the best explanation. Thanks!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Trivikram</title>
		<link>http://www.learnphponline.com/php-basics/how-to-find-the-current-url-in-php/comment-page-1#comment-8462</link>
		<dc:creator>Trivikram</dc:creator>
		<pubDate>Thu, 03 Mar 2011 10:53:20 +0000</pubDate>
		<guid isPermaLink="false">http://www.learnphponline.com/?p=114#comment-8462</guid>
		<description>Hi Thanks for the post. I applied this for my wordpress site, and it is not working. I dont know why ??? Can You Help me ??</description>
		<content:encoded><![CDATA[<p>Hi Thanks for the post. I applied this for my wordpress site, and it is not working. I dont know why ??? Can You Help me ??</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Barton</title>
		<link>http://www.learnphponline.com/php-basics/how-to-find-the-current-url-in-php/comment-page-1#comment-4583</link>
		<dc:creator>Barton</dc:creator>
		<pubDate>Mon, 01 Nov 2010 09:29:08 +0000</pubDate>
		<guid isPermaLink="false">http://www.learnphponline.com/?p=114#comment-4583</guid>
		<description>Hi,

interesting article.

One question, how do you get hold of the rewritten URL?

Thanks</description>
		<content:encoded><![CDATA[<p>Hi,</p>
<p>interesting article.</p>
<p>One question, how do you get hold of the rewritten URL?</p>
<p>Thanks</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: kaki</title>
		<link>http://www.learnphponline.com/php-basics/how-to-find-the-current-url-in-php/comment-page-1#comment-3947</link>
		<dc:creator>kaki</dc:creator>
		<pubDate>Wed, 13 Oct 2010 19:22:08 +0000</pubDate>
		<guid isPermaLink="false">http://www.learnphponline.com/?p=114#comment-3947</guid>
		<description>Thanks helped me with collecting info about people :)</description>
		<content:encoded><![CDATA[<p>Thanks helped me with collecting info about people <img src='http://www.learnphponline.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
</channel>
</rss>

