{"id":291,"date":"2006-11-17T14:25:55","date_gmt":"2006-11-17T14:25:55","guid":{"rendered":"http:\/\/neosmart.net\/blog\/archives\/291"},"modified":"2013-08-26T18:13:17","modified_gmt":"2013-08-26T23:13:17","slug":"100-apache-compliant-request_uri-for-iis-and-windows","status":"publish","type":"post","link":"https:\/\/neosmart.net\/blog\/100-apache-compliant-request_uri-for-iis-and-windows\/","title":{"rendered":"100% Apache-Compliant REQUEST_URI for IIS and Windows!"},"content":{"rendered":"<p>Ever since moving NeoSmart Technologies to a Windows server, we&#8217;ve had one headache after the other dealing with various PHP scripts that included references to <code>$_SERVER[\"REQUEST_URI\"]<\/code>, and unfortunately, none of the &#8220;workarounds&#8221; or hacks provided on the internet work. Some of them are for Apache on Windows, and others work most of the time, but break the minute you introduce url rewriting or launch scripts as the default files in a directory.<\/p>\n<p>REQUEST_URI for Windows is a must-install for absolutely anyone that uses IIS &amp; PHP, no matter what software you run. It&#8217;s <strong>free<\/strong>, it&#8217;s <strong>one-hundred percent compatible<\/strong> with Apache&#8217;s own REQUEST_URI, and best of all, <strong>it&#8217;s guaranteed to work<\/strong> no matter what. REQUEST_URI for Windows gets whatever the user entered into the address bar &#8211; period. Nothing more, nothing less. And of course, you never have to modify a single script to make them work, this does all the work for you.<\/p>\n<p><!--more--><\/p>\n<p>If you&#8217;re still reading till this point, you&#8217;re probably wondering where the code is. Unfortunately, it&#8217;s not that simple. First, we make one assumption: this requires that you be the administrator\/owner of the server you want to deploy this on. It&#8217;s not nice, we know, but such functionality only comes from the very top &#8211; ISAPI filters. But that&#8217;s not too bad, most people on shared hosts use <abbr title=\"Linux, Apache, MySQL, &amp; PHP\">LAMP<\/abbr> servers, and most Windows server users either own or administrate their server anyway.<\/p>\n<p><strong>If you don&#8217;t have administrative privileges, skip on ahead!<\/strong><\/p>\n<p><strong>Requirements<\/strong><\/p>\n<ul>\n<li><a href=\"http:\/\/www.helicontech.com\/isapi_rewrite\/\" rel=\"follow\">This ISAPI filter<\/a> &#8211; to get the info we need (the free, lite version works just fine for our needs);<\/li>\n<li>NeoSmart Technologies&#8217; <a title=\"NeoSmart Technologies Request_URI for Windows\" href=\"http:\/\/neosmart.net\/IISRequestURI\/\" rel=\"follow\">request_uri.inc<\/a>;<\/li>\n<\/ul>\n<ol>\n<li>Download and install ISAPI_Rewrite, the (partially free) mod_rewrite imitation for IIS. All it takes is one click, it&#8217;ll automatically setup everything for you and take care of installing the ISAPI filters.<\/li>\n<li>Download and extract <a href=\"http:\/\/neosmart.net\/IISRequestURI\/\" rel=\"follow\">request_uri.inc<\/a> to the location of your php.ini (your PHP home).<\/li>\n<li>Open your PHP home directory (where php.ini is), and locate the following lines:\n<pre>auto_prepend_file =\r\nauto_append_file =<\/pre>\n<p>and change them to<\/p>\n<pre>auto_prepend_file = \"c:\/php\/request_uri.inc\"\r\nauto_append_file =<\/pre>\n<p>\nWhere &#8220;c:\/php\/&#8221; is replaced with the directory where you extracted request_uri.inc<\/li>\n<li><strong>The following step is only for users of ISAPI_Rewrite 2.x<br \/>\nIf you&#8217;re using ISAPI_Rewrite 3.x, skip ahead to step 5!<\/strong><\/p>\n<p>Open up Start | Programs | Helicon | ISAPI_Rewrite | Httpd.ini<\/p>\n<p>On a blank line <em>at the beginning of the document<\/em>, copy and paste the following:<\/p>\n<pre># Defining $_SERVER['HTTP_REQUEST_URI']\r\nRewriteCond %{URL} (.*)\r\nRewriteHeader REQUEST_URI: . %1\r\n# End HTTP_REQUEST_URI<\/pre>\n<p>\n<\/li>\n<li>Open the IIS Admin Console, and restart the IIS service (or use the command prompt to do the same: iisreset.exe).<\/li>\n<li>You&#8217;re done! Now any time a script calls up <code>$_SERVER[\"REQUEST_URI\"]<\/code>, NeoSmart Technologies&#8217; script will dynamically update it to the <strong>real<\/strong> value, as if you weren&#8217;t on a <abbr title=\"Windows, IIS, MySQL, &amp; PHP\">WIMP<\/abbr> server!<\/li>\n<\/ol>\n<p>With our Request_URI for Windows script, you won&#8217;t have to <em>ever<\/em> modify another PHP script just to make it correctly detect the contents of REQUEST_URI &#8211; then discover it doesn&#8217;t actually work. All NeoSmart-Technologies&#8217; code used in the process is released under the LGPL, so you can use it wherever you like without a problem.<\/p>\n<p>If you don&#8217;t have administrative rights on the machine in question, you can still use our <a href=\"http:\/\/neosmart.net\/IISRequestURI\/\" rel=\"follow\">request_uri.inc<\/a> to a limited extent. It&#8217;s not exactly 100% compatible, but it comes near it. Just put our file in the same directory as your script and add<\/p>\n<pre>require(\"request_uri.inc\");<\/pre>\n<p>to the top of your script &#8211; it just might be enough for your needs.<\/p>\n<p>If you face any problems getting this to work, the support forums are only <a href=\"http:\/\/neosmart.net\/forums\/forumdisplay.php?f=17\" rel=\"follow\">a click away<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Ever since moving NeoSmart Technologies to a Windows server, we&#8217;ve had one headache after the other dealing with various PHP scripts that included references to $_SERVER[&#8220;REQUEST_URI&#8221;], and unfortunately, none of the &#8220;workarounds&#8221; or hacks provided on the internet work. Some &hellip; <a href=\"https:\/\/neosmart.net\/blog\/100-apache-compliant-request_uri-for-iis-and-windows\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[1],"tags":[83,579,124,676,142,141,4],"class_list":["post-291","post","type-post","status-publish","format-standard","hentry","category-software","tag-iis","tag-isapi_rewrite","tag-php","tag-request_uri-for-iis","tag-servers","tag-wimp","tag-windows"],"aioseo_notices":[],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/p4xDa-4H","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/neosmart.net\/blog\/wp-json\/wp\/v2\/posts\/291","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/neosmart.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/neosmart.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/neosmart.net\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/neosmart.net\/blog\/wp-json\/wp\/v2\/comments?post=291"}],"version-history":[{"count":1,"href":"https:\/\/neosmart.net\/blog\/wp-json\/wp\/v2\/posts\/291\/revisions"}],"predecessor-version":[{"id":2176,"href":"https:\/\/neosmart.net\/blog\/wp-json\/wp\/v2\/posts\/291\/revisions\/2176"}],"wp:attachment":[{"href":"https:\/\/neosmart.net\/blog\/wp-json\/wp\/v2\/media?parent=291"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/neosmart.net\/blog\/wp-json\/wp\/v2\/categories?post=291"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/neosmart.net\/blog\/wp-json\/wp\/v2\/tags?post=291"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}