I am not very familiar with IIS7 and I need to create a server variable so that I can access it within my PHP code. I can easily accomplish this in Apache by using:
SETENV variable_name variable_value
in the .htaccess file. However accomplishing this in IIS seems to be a bit of a secret. I have looked online for info and the closest thing I can find states using the URL Rewrite Module using these steps:
Clicking on View Server Variables
Click the Add link and enter the variable name
Go back to rules and click the View Rewrite Maps
Click Add Rewrite Map and enter the default value.
Restarted the server.
Full docs can be found at: http://www.iis.net/learn/extensions/url-rewrite-module/setting-http-request-headers-and-iis-server-variables
I followed that but it still doesn’t work. Any ideas how this is done? Is it even possible to do this in IIS? All I want to do is set up a server variable with a static value.
example: $_SERVER['MY_VARIABLE']
Thanks.
In IIS Manager click on your machine, open the "URL Rewrite" icon from the "IIS" icon group.
Under "Actions" (on the extreme right) click the innocuous little "View Server Variables" link, disregarding "Manage Server Variables"
In the "View Server Variables" screen's "Actions" (on the extreme right) click "Add..."
I solved this by using the PHP auto_prepend_file directive. More information can be found here: http://www.php.net/manual/en/ini.core.php#ini.auto-prepend-file
Just create a file that adds the desired value to the $SERVER array, set that as the auto_prepend_file and you are good to go. This will work with any server, not just IIS.
The other answers clearly work, but seems messier than the way I found.
Go to FastCGI settings, where you have the PHP exe configured (per the original question)
Right click on ...\php-cgi.exe, select "Edit"
Then choose the ellipses next to "Environment Variables"
Then you can click add/remove and edit your variables.
Related
I am a super beginner and am learning as I go, so please be patient with me!
So here goes:
I am trying to make some edits on a Magento theme (removing buttons - Twitter, to be exact) and am using FireBug (Firefox Add-On) to locate the directory to remove the button.
Firebug will allow me to find the CSS directory in order to change certain things but does not show the file to make edits in to remove the button. From other similar questions, I have gathered that it is not possible to find server directory paths from apps like Firebug (or is it?); however, is there any advice or easier method to go about finding the location of the button?
Any information helps, thanks in advance.
Indeed, you cannot use firebug to find in which file that button is inserted. You have to go to magento admin, system- > configuration -> developer. Select your website in view top left. then in template path hints select yes. Now go into frontend and refresh. You will see a lot of red lines with the path to the folders where everything is. Do not do this in production as it is a negative experience for customers.
try saving the file locally by doing ctrl + s. That may give you the css file to make changes.
Check this step by step instruction:
Step 1: System >> Configuration >> Developer
your current configuration scope is set to “Default Config.” You cannot setup Magento Template Path Hints globally. You’ll need to set the Configuration Scope to a website or store configuration. When you do, you’ll see a screen like this:
Change Template Path Hints no to yes and save the configuration. Reload your front page.
For more info
In IIS7 I right click on the site and choose "Switch to content view" then add a text file called test.txt right click again and switch to features view. Double click the http redirect icon and see it's not forwarding.
Right click the site and switch to content view again now right click on test.txt and choose browse only to be forwarded to some other site that gives me 404 for not having /test.txt.
I don't know where to look anymore as the settings mentioned above would indicate there would be no forwarding but opening the file proves that it does.
When using forcecors plugin for firefox and making a ajax request to the text file I can see the response header: Location http://some_other_site/test.txt.
Hope it's something simple.
[update]
In the application I checked out the settings under "Url rewrite" and found a rule that redirects. Removed this rule and stopped started IIS but it's still forwarding. Could not find anything under System32\inetsvr\config that would indicate redirecting.
After removing the url rewrite rule and testing in the browser it kept on forwarding because I think my browser remembered it was moved. Cache settings on IIS should check if file has changed after it was last cached (I think last modified headers) but somehow a redirect works differently. Did not clear my browser cache and even doing that could still cause a problem with proxies caching it.
What I did was opening it this way:
http://develop.mysite.com/test.txt?refresh=newValue
Like magic I wasn't redirected and it works now. Start FF with another profile and see if that solves the problem as the new profile should not be aware of the sites response being "permanently moved" by a previous request.
On my Windows Server 2008 R2 server, I've set the:
"Region and Language" -> "Formats" -> "Danish (Denmark"
When I see the settings here, and when I click the "Additional Settings", it seems correct. However, in my application, it is not set correct. Here my output is still American.
For instance, these two situations I get the problem:
Datetime.ToString() gives 11/4/2012 1:18:38 PM instead of 04/11/2012 13:18:38 .
When I input a double with 50,00 it is ignored and is set to 5000. When using a dot, it works. it should be a decimal
Of course I could all set this in the application specifically, but I wonder why it is set to English as default when I've set the Formats to Danish.
I've also set the following:
Location = "Denmark"
Default Input Language = "Danish"
How do I fix it? :-)
ASP.NET runs under a different user account, so you'll need to copy the regional settings across.
In the Region and Language control panel, on the Administrative tab, you should have a Copy settings... button. This will copy the settings from your account to the welcome screen, system accounts and new user accounts.
Another thing to check would be the <globalization> section in your web.config file - you might be picking up the culture settings from the user's browser.
In my ASP.NET MVC application, I am referencing background images via CSS. When I run it in the dev environment, they show up fine. But when I deploy it (using IIS 7.5) the images do not load at all. I have tried every combination of relative paths and background/background-image CSS tags, but nothing works. Here is my file structure and CSS:
File structrue:
Content
CSS file
images
image.png
CSS:
background-image: url(/images/bsb_header2.png);
I have also tried ../images/bsb_header2.png and ../../images/bsb_header2.png to no avail.
What is really strange is when I try to go to the image directly (i.e. www.website.com/images/image.png), I am redirected to a login page. Perhaps there is some access or security setting I'm missing? I haven't done anything with login controls yet (the default account view and controller are in my project but I haven't done anything with them yet) and I can view all my other pages just fine.
Update: I FINALLY figured it out. The image file in question was encrypted. Right click the image file and navigate to properties, click the advanced button on the general tab, uncheck "Encrypt contents to secure data", click OK, OK.
The tip off finally came when I noticed the file name was green in Windows Explorer. I see green file names all the time with no problems so I didn't think anything of it. Then I noticed it was the only green file in the entire web app folder. Put two and two together and it worked instantly. Thanks everyone for your help.
Please Add two users
IUSR,
IIS_IUSRS
to the publish folder and assign permission for them to read & execute
I FINALLY figured it out. The image file in question was encrypted. Right click the image file -> properties -> advanced button on general tab -> uncheck "Encrypt contents to secure data" -> OK -> OK.
The tip off finally came when I noticed the file name was green in windows explorer. I see green file names all the time with no problems so I didn't think anything of it. Then I noticed it was the only green file in the entire web app folder. Put 2 and 2 together and it worked instantly. Thanks everyone for your help.
Is it possible that IIS 7.5 was not installed correctly?
If you go to Turn Windows Features on or off - under:
Internet Information Services /
World Wide Web Services /
Common Http Features
there is a Static Content checkbox
is it checked?
see this link for screen-shot.
in css set "display: block"
.searchbtn
{
margin-top:-15px;
background-image:url(../images/icons/search.png);
background-repeat:no-repeat;
width:18px;
height:18px;
display: block;
}
The URL should be relative!
background-image: url(images/bsb_header2.png)
From your description, it appears as if the Request for the .png is getting routed to the ASP.NET/MVC engine instead of being served up by IIS.
Is it possible that the routing rules in the Global.asax are picking .png files? (I know this doesn't explain why it works in your dev environment).
Does it work if you add a ignoreRoute for .png files at the beginning of your route list in Global.asax? Something like below...
routes.IgnoreRoute("{resource}.png");
Had the same issue and finally found a solution.
In IIS open "Authorization Rules".
If there is nothing there, click "Add Allow Rule"
Choose "All Users" and hit OK
Request.RawUrl always returns the /default.aspx variant. I did not find any way at all to differentiate between these urls. Does anybody know how to do that?
Environment is .NET 3.5SP1 on IIS 7.
I actually had to combat this same problem when designing my URL Rewriter. It has to do with the processes that occur before you can even access the URL's. To get around this you have to make sure that in IIS 7 the default page handling is turned off. Because if there is no default page handling it is not going to go through the extra step of trying to map it to the drive, so you will be the exact URL requested. But this may or may not be an option depending on if you are using System.Web.Routing or not.
To turn off the default page handling you need to do the following:
Go to your site in IIS
Go to Default Document
Click Disable in the top right corner.
Or you can add the following to your web.config:
<system.webServer>
<!-- ... other tags here ... -->
<defaultDocument enabled="false" />
</system.webServer>
After you do this the default document will be no longer added to your URL. However be warned that since this is no longer active you cannot rely on default.aspx actually mapping to your directories, you will have to handle this manually or use something like System.Web.Routing to handle this functionality.
To accomplish the same in IIS 6 you need to turn on wildcards:
The following instructions apply for IIS 6.
Open IIS and right-click on the website and select 'properties'.
Click the 'Configuration' button under Application Settings section
Click the 'Insert...' button to create a new wildcard mapping
Set the executable textbox to aspnet_isapi.dll file location.
for .net 2.0, 3.0, 3.5: C:\Windows\Microsoft.NET\Framework\v2.0.50727\aspnet_isapi.dll
Make sure the checkbox 'Verify that file exists' is not checked.
Press 'OK' to confirm and close all the windows.
NOTE: by the way all the source is available on the site I linked above incase you were curious how I was doing things.