Can anyone help me?...Wordpress permalinks and IIS6

Sep 21, 2009 at 9:35 PM

Hi

I cannot solve a problem I am having with permalinks on my wordpress blog. I am on shared windows hosting with IIRF rewriter preinstalled. I am hosting my blog at mydomain.com/blog/.

When I try to change permalinks from anything but default my entire blog 404s. Someone has been kind enough to help me, but both of us are still trying to work this out. We have created the follwoing rewrite rules:

RewriteEngine On

MaxMatchCount 1
RewriteCond %{HTTP_HOST} (^www.mydomain.com) [I]
RewriteRule ^/(.*) http://mydomain.com/$1 [I,RP]

MaxMatchCount 10

RewriteBase /

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /blog/index.php [L]

My blog is now sitting at mydomain.com and when I change permalinks well it works perfectly, but now the subfolder 404's. Does anyone know how I get my blog back to my subfolder and get my permalinks pretty?

Please help! This is driving me crazy!

ps. please note, I'm not a techy although the person kind enough to help me is!

Thanks

Kerry

 

Coordinator
Sep 22, 2009 at 6:57 AM

Step 1:  Read the IIRF doc.  You have statements in your ini file that are not supported byb IIRF.  There is no [RP] modifier, as far as I know.  There is no RewriteBase directive.

what does this mean:  "My blog is now sitting at mydomain.com and when I change permalinks well it works perfectly, but now the subfolder 404's. Does anyone know how I get my blog back to my subfolder and get my permalinks pretty?"

I'm sure you understand that, but I don't.   "when I change permalinks well it works perfectly, but now the subfolder 404s".  I guess you're getting a 404, but I don't know what the subfolder is, and I don't know what you expect.  I don't know what "when I change permalinks well" means. 

normally I can help people who say something like "I have an internal URL like Y and I want my external URL to look like X.  Can you help me produce a rewriterule?  So far I have this:  ZZZZ". 

 

 

Sep 22, 2009 at 8:27 AM

Sorry, maybe didn't make myself clear enough. I am new to rewrite rules so please be patient with me as I am just asking for some help as I cannot find anyone who can help me at this stage.
 
My wordpress blog sits on www.mydomain.com/blog/. There is a known issue with wordpress urls and IIS servers when trying to change the url structure of wordpress blogs via their admin panel so that urls are search engine friendly. This is normally a simple edit in the Wordpress dashboard if the blog is on a non-windows server.

However, there is no information I can find on the internet that details what rewrite rule to use to get the wordpress blog urls working using IIRF when the blog is in a subdirectory ie. www.mydomain.com/blog/  All solutions refer to when the blog is the root domain ie. www.mydomain.com and those aren't working for me and I have no idea what to change.
 
When I try to change permalinks ie. the blog urls from default www.mydomain.com/blog/index.php/p?=1 to www.mydomain.com/blog/%category/%postname%/ in the Wordpress dashboard it results in a 404 when I go to www.mydomain/blog/ when what it should result in is a search engine friendly blog with urls like www.mydomain.com/category1/blog-post-headline-here
 
All I want is a rewrite rule that will enable me to change these urls without resulting in a 404 so that I can enter the custom url stucture I would prefer.

Coordinator
Sep 22, 2009 at 10:05 AM

ah, well it sounds like there is some rewriting built-in to Wordpress that is not working very well.

I don't know what %category% and %postname% refer to, but URLs of that type won't work vevry well unless there is some dispatcher page that *all* requests get rewritten to.  That dispatcher page within wordpress must be able to retrieve the original pre-rewrite URL.  You can do this in IIRF - it gets set in the server variable "HTTP_X_REWRITE_URL", if you apply the [U] option to the RewriteRule.  But this will work only if the dispatcher page in wordpress knows to reference that server var to do the routing.   I think, from reading Wordpress docs, that the server variable it is looking for is REQUEST_URI. This isn't gonna work. 

Some people are able to change a single wordpress file to get this to work.  For example, add the following line of code at the beginning of wp-settings.php:

$_SERVER['REQUEST_URI'] = $_SERVER['HTTP_X_REWRITE_URL'];

But I don't know wordpress and I'm not sure it will work for you.  

if you do this you would still need the iirf.ini file:

RewriteEngine On

MaxMatchCount 2
RewriteCond %{HTTP_HOST} (^www.mydomain.com) [I]
RedirectRule ^/(.*) http://mydomain.com/$1 [I,R=301]

# RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /blog/index.php [L,U]

I can't really help you beyond this basic hint. 

 

 

Coordinator
Sep 22, 2009 at 10:09 AM

There are other sites that suggest this is the correct ini file to use with wordpress:

RewriteRule ^/sitemap.xml$   - [L]
RewriteRule ^/(?!index.php)(?!wp-)(.*)$ /index.php/$1

As I said, I don't know wordpress so not sure which is preferred or why.

Coordinator
Sep 22, 2009 at 10:16 AM
Edited Sep 22, 2009 at 3:18 PM

Here's another post that recommends something different.

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^/(.*)$ /index.php [L,U] 

it doesn't say anything about modifying the wp-settings.php file.

May 29, 2010 at 4:19 PM

I had this problem as well. You have to modify the IsapiRewrite4.ini file. The rewrite rules in my file are:

RewriteRule ^/wp-admin/([^/]+)$  /wp-admin/$1
RewriteRule ^/([^/]+)/([^/]+)/([^/]+).html$  /index.php?p=$1
RewriteRule ^/comments/feed /index.php?feed=comments-rss2
RewriteRule ^/([^/]+)/([^/]+)$  /index.php?page_id=$1

Then you must add a rule EVERY TIME you add a new page or post:

#Add a rule for each page you wish to add in your blog.  Lookup the page id from the admin section of wordpress
RewriteRule ^/portfolio  /index.php?page_id=9
RewriteRule ^/services  /index.php?page_id=11

However, I'm currently on the forum looking for another rewrite rule to make the drop-down menus work in Thesis. My regular links for pages, blog posts, and archvies all work fine with the rules above. The drop-down menus work but always take the user to the parent page instead of the child page.

I may be moving the entire domain to a Linux server to get around this crap.

Coordinator
May 29, 2010 at 4:57 PM
Edited May 29, 2010 at 4:59 PM

To avoid having to add a rule for every page you create in wordpress, with IIRF v2.1, you can use a RewriteMap, that maps a string to a page id. In your case the map file would look like this:

  portfolio    9
  services     11

And if you name that file, c:\whatever\pagemap.txt , the ini file would look like this:

   RewriteMap  pagemap   txt:c:\whatever\pagemap.txt
   RewriteRule ^/(.*)   /index.php${pagemap:?$1|}  

It should be simple to automatically produce the map file, using a script configured as a scheduled task, or similar. The result would be that you'd never have to change your ini file, when you post new pages.

I don't know about thesis drop-down menus so I can't help with that.