I want to be able to rewrite a url using url rewriting in IIS 7 whenever an anonymous user hits the home page of my wordpress site. Is there a way to identify whether the user is logged in or not as a condition of a rewrite rule?
Leave a Reply
You must be logged in to post a comment.
Turns out this can be done by inspecting the cookie. In my case, I check to see whether HTTP_COOKIE contains the text ‘wordpress’. If it does not, then I rewrite to a cached version of my page.
I also include a check to make sure we are on the www subdomain to avoid any conflict with another of my rewrite rules that is run when the url is on mydomain.com.
The result is that anonymous users get the cached page, while logged in / recently logged out users see the standard page loaded by WordPress.
Note: There are some additional checks that should possibly be added to handle some other scenarios. Here is a good article with a more robust example http://ruslany.net/2008/12/speed-up-wordpress-on-iis-70/