Archive for the 'URLRewrite' Category

RuslanY.net running on Windows Azure Web Sites

I have not been writing any blog posts for a while. That was because for the past two years I have been busy working in a team that develops the Windows Azure Web Sites – a scalable web hosting platform in Windows Azure.

Now that the Windows Azure Web Sites (WAWS) is publicly available I decided to try to move my site from private hosting  to Windows Azure. My site uses WordPress (with MySql database), PHP 5.3, WinCache object and user cache, URL rewriting and many WordPress plugins. With all these different technologies (many of which are not developed by Microsoft), I thought it would be a good test of how WAWS is capable of running web sites that use open source technologies. Plus I expect that my site will be more reliable and available, comparing to my previous private hosting.

I was pleasantly surprised that the migration from private hosting to WAWS hosting was relatively quick and simple. The site has been running successfully in a Shared compute mode for a while now and none of the site’s functionality has been lost or altered. In this post I’ll explain the steps I took to move my site to WAWS hosting. Hopefully it will be useful to those who are planning to migrate their WordPress based site to WAWS. Continue Reading »

6 Comments »

ruslany on October 22nd 2012 in PHP, URLRewrite, WAWS, WinCache, WordPress

72,204 views

PoorFairAverageGoodExcellent (2 votes, average: 5.00 out of 5)

Storing URL rewrite mappings in a separate file

When using rewrite maps in IIS URL Rewrite it is very common to have a very large number of entries in a rewrite map. In order to avoid cluttering the configuration file - web.config - with this configuration data the rewrite maps can be defined in a separate configuration file. That file can then be referenced from the web.config file. This post provides an example of how this can be done.

Create a file called rewritemaps.config in the same directory where web.config file is. Open that file in notepad and add the following:

<rewriteMaps>
  <rewriteMap name="Redirects">
    <add key="/oldurl" value="/newurl" />
    <add key="/otheroldurl" value="/othernewurl" />
  </rewriteMap>
</rewriteMaps>

Save this file and then open web.config file in notepad. In the web.config file add the following inside of the <rewrite> section:

<rewriteMaps configSource="rewritemaps.config" />

The configSource attribute tells IIS configuration that the <rewriteMaps> section is defined in a separate file rewritemaps.config. This referenced section can be now uses as if it was defined in the same web.config file. Also, the IIS Manager UI will work well with this referenced file: when you modify or add entries to the rewrite map they will be stored in the rewritemaps.config file.

Here is a complete example web.config file that uses the rewrite map from referenced configuration file:

<configuration>
<system.webServer>
  <rewrite>
    <rewriteMaps configSource="rewritemaps.config"><rewriteMaps>
    <rules>
      <rule name="Redirect rule1 for Redirects">
        <match url=".*" />
        <conditions>
          <add input="{Redirects:{REQUEST_URI}}" pattern="(.+)" />
        </conditions>
        <action type="Redirect" url="{C:1}" appendQueryString="false" />
      </rule>
    </rules>
  </rewrite>
</system.webServer>
</configuration>

The same approach can be used for storing rewrite rules in a separate configuration file, e.g.:

<rules configSource="rewriteRules.config" />

26 Comments »

ruslany on May 19th 2010 in URLRewrite

61,513 views

PoorFairAverageGoodExcellent (6 votes, average: 5.00 out of 5)

Visual Studio XML IntelliSense for URL Rewrite 2.0

Last year I published an XML schema for URL Rewrite 1.1 that could be used to enable IntelliSense support when editing rewrite rules in Visual Studio XML editor. Now that the URL Rewrite 2.0 has been released, the old schema will not work for the the new configuration elements introduced in the v2.0. Use the link below to download the schema for URL Rewrite 2.0:

VS IntelliSense for URL Rewrite 2.0

Disclaimer: The schema file and the helper script file contained in this package are provided by me and not by Microsoft. They are not officially supported by Microsoft. Use them at your own risk.

Follow the same instructions as in Visual Studio XML IntelliSense for URL Rewrite 1.1 to add the schema to the Visual Studio schema cache. If after following the instructions the IntelliSense does not work then follow the instructions at Not getting IntelliSense in your web.config for system.webServer sections in Visual Studio 2008?.

27 Comments »

ruslany on April 23rd 2010 in URLRewrite

24,870 views

PoorFairAverageGoodExcellent (9 votes, average: 4.89 out of 5)

Time-dependent URL rewriting

This post explains how to configure time-dependent URL rewriting rules by using IIS URL Rewrite 2.0. Time-dependent URL rewriting may be useful when you want to rewrite or redirect HTTP requests based on the time of day or when you need to take the entire site or some parts of the site offline for a scheduled period of time.

The rewrite rules are not time-aware, but it is relatively easy to add the time-dependent functionality by using URL Rewrite 2.0 extensibility. Follow the steps below to add a scheduler rewrite provider for URL Rewrite module. Continue Reading »

1 Comment »

ruslany on April 4th 2010 in URLRewrite

7,925 views

PoorFairAverageGoodExcellent (5 votes, average: 4.20 out of 5)

IIS URL Rewrite 2.0 – Release to Web

The IIS URL Rewrite Module 2.0 – RTW is available for download. IIS URL Rewrite v2.0 is an incremental release that includes all the features from version 1.1, and adds extensibility support and outbound response rewriting. More specifically, v2.0 can be used to:

  • Express complex URL rewriting logic by using custom rewrite providers written in .NET.
  • Replace the URLs generated by a web application in the response HTML with a more user friendly and search engine friendly equivalent
  • Fix up the content of any HTTP response by using regular expression pattern matching.
  • Modify HTTP request and response headers and IIS server variables.

For the complete list of features available in this version, refer to Using URL Rewrite Module 2.0.

Install the URL Rewrite 2.0 – RTW

To install the URL Rewrite 2.0, use the download links at the module’s home page at http://www.iis.net/expand/urlrewrite. Note that this is a final, production ready release that is officially supported by Microsoft.

Upgrade notes:

  • If a previous version of URL Rewrite Module, such as v1.0 and v1.1, is already installed then it will be upgraded to the v2.0;
  • If an RC version of the URL Rewrite Module 2.0 is already installed, then it will be upgraded to RTW version. Continue Reading »

27 Comments »

ruslany on March 11th 2010 in URLRewrite

4,640 views

PoorFairAverageGoodExcellent (11 votes, average: 3.55 out of 5)

URL Rewrite Module v2 – Release Candidate

The URL Rewrite Module 2.0 – Release Candidate is available for download. The release contains functionality and stability improvements and it is believed to have a quality level suitable for production deployments.

Overview

Microsoft URL Rewrite Module 2.0 for IIS 7 is an incremental release that includes all the features from version 1.1, and adds support for outbound response headers and content rewriting. More specifically, it can be used to:

  • Replace the URLs generated by a web application in the response HTML with a more user friendly and search engine friendly equivalent
  • Modify the links in the HTML markup generated by a web application behind a reverse proxy.
  • Fix up the content of any HTTP response by using regular expression pattern matching.
  • Modify HTTP request headers and IIS server variables.
  • Modify HTTP response headers

Install the URL Rewrite Module 2.0 – RC

To install the URL Rewrite Module 2.0 – RC, use the download links at the module’s home page at http://www.iis.net/extensions/urlrewrite. Continue Reading »

5 Comments »

ruslany on November 9th 2009 in URLRewrite

7,451 views

PoorFairAverageGoodExcellent (6 votes, average: 4.33 out of 5)

Enable PHP Syntax Highlighting on IIS 7

This post describes how to configure IIS 7 to output syntax highlighted source code for PHP files stored on the web server or site. This feature may be useful for development environments when you want to quickly make the source code accessible to other team members.

WARNING: Never attempt to do what is described below on any internet accessible web site! Doing so will greatly compromise the security of your web application.

The HTTP requests for the PHP source code are usually identified by the “.phps” file extension, e.g. http://localhost/index.phps. You will need to configure IIS to understand and handle the HTTP requests with this extension. There are two options for that: to create an IIS handler mapping for “*.phps” or to use the IIS URL Rewrite Module. Continue Reading »

2 Comments »

ruslany on October 6th 2009 in PHP, URLRewrite

7,815 views

PoorFairAverageGoodExcellent (5 votes, average: 3.40 out of 5)

Visual Studio XML IntelliSense for URL Rewrite 1.1

If you ever tried to write or modify rewrite rules in web.config file by using Visual Studio 2008 XML Editor, you may have noticed that the Visual Studio XML IntelliSense does not work for all URL Rewrite Module configuration elements. This is because the XML schema for <rewrite> element is not registered in Visual Studio Schema Cache. This post provides the instructions on how to register URL Rewrite schema with Visual Studio to enable IntelliSense support.

To enable IntelliSense support for URL Rewrite 1.1 follow these steps: Continue Reading »

28 Comments »

ruslany on August 13th 2009 in URLRewrite

39,962 views

PoorFairAverageGoodExcellent (10 votes, average: 4.30 out of 5)

URL Rewrite Module 2.0 for IIS 7 – Beta

Today IIS team has released the URL Rewrite Module 2.0 for IIS 7 – Beta. This is an incremental release that includes all the features from version 1.1, and adds support for outbound response rewriting. More specifically, it can be used to:

  • Replace the URLs generated by a web application in the response HTML with a more user friendly and search engine friendly equivalent
  • Modify the links in the HTML markup generated by a web application behind a reverse proxy.
  • Fix up the content of any HTTP response by using regular expression pattern matching

Install the URL Rewrite Module 2.0 Beta

wpibadgesilver

or, download:

URL Rewrite Module 2.0 for IIS 7 – Beta (x86)

URL Rewrite Module 2.0 for IIS 7 – Beta (x64)

Continue Reading »

7 Comments »

ruslany on July 16th 2009 in URLRewrite

14,569 views

PoorFairAverageGoodExcellent (1 votes, average: 5.00 out of 5)

Upgrade to WordPress 2.8 and PHP 5.3 on IIS 7

Today I have upgraded my blog to the recently released WordPress 2.8 and to PHP 5.3 RC3 (VC9 Non Thread Safe build). If you are running WordPress (or any other PHP application) on IIS 7, then there are several reasons why it may be beneficial for you to upgrade:

  • PHP 5.3 has a number of Windows-specific bug fixes and improvements that address stability and functionality problems which existed before when running PHP on Windows. For detailed list of all the changes and fixes, refer to the news.txt file included within the PHP zip file.
  • PHP 5.3 has been compiled with the latest version of C compiler (VC9), which makes it run faster on Windows than any previous versions of PHP (which were compiled with VC6).
  • WordPress 2.8 has built-in support for IIS 7 URL Rewrite Module. Refer to IIS 7 URL Rewrite Module support in WordPress 2.8 for more details.

Overall, the upgrade went pretty smoothly and the only thing that was different from the usual process of setting up PHP on Windows was the date.timezone setting in php.ini file. Starting with PHP 5.3, this setting must be explicitly set, e.g.:

date.timezone = America/Los_Angeles

After this successful upgrade I guess it is time now “to reward myself by reading that book or an article that I’ve been putting off, or simply sitting back for a few moments and let the world pass me by”.

Have you tried upgrading to PHP 5.3 on IIS recently? What was your experience?

24 Comments »

ruslany on June 11th 2009 in PHP, URLRewrite, WordPress

53,048 views

PoorFairAverageGoodExcellent (4 votes, average: 3.75 out of 5)

Recently Published Articles