When developing PHP applications it's common to have a public folder somewhere in the application structure at which the webserver is targeted. The private application code is stored outside this directory so it is not publicly accessible.
I've a PHP application I'm trying to run on Azure and want to configure a directory within my WebRole to be the 'public directory', but in Eclipse (I'm using the PHP Azure plugin) I don't see any options to configure it. Is there any way to configure the actual 'root' directory of the role? Or is the role inherently public, 开发者_如何学JAVAand therefore I should be storing my private code somewhere else and sharing it with the WebRole?
By default, the root of the website is always public on the IIS configuration in Windows Azure. However, since URL rewriting is supported, it's pretty easy to overcome this.
Just as with .htaccess and mod_rewrite on Apache, you can rewrite the current request to a different folder. IIS will use this information internally to find your files, but the user's browser will never notice this rewrite happens.
Here's a portion of XML that you can copy/paste in your Web.config file. The public root in the below code is "public", if this is "shizzle" make sure to change that :-)
<!-- Rewrite rules to /public -->
<rewrite>
<rules>
<clear />
<rule name="TransferToPublic" patternSyntax="Wildcard" stopProcessing="true">
<match url="*" />
<action type="Rewrite" url="public/{R:0}" />
</rule>
</rules>
</rewrite>
For reference: this is to be located under the XML node.
Another option is "building your own role", like I partially did in this post Lightweight PHP application deployment to Windows Azure. By tweaking some of the files, you can trick IIS into a different public root. If you use my blog post for the packaging part for Azure and use Google/Bing/MSDN for the IIS configuration part, this should also work.
Enjoy!
精彩评论