Help with rewrite rules?

Topics: Developer Forum
Nov 24, 2011 at 11:05 AM
Edited Nov 24, 2011 at 11:06 AM

I have a WordPress install in a sub folder that is set up on Windows Server 2003 & IIS6 and is configured as a separate virtual directory / application.

Everything seems to work great with the following rules EXCEPT when a user adds a product to their basket within a WooCommerce store - instead of being added the url goes to something like:

www.mysite.com/shopname/product-category/product-name/?add-to-cart=variation&product=192&_n=ec663eec54

RewriteBase /webshop-new/
RewriteCond $1 !\.(gif|jpe?g|png)$ [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L,U] 

If I change the above to have the following line in after the image rule it works ok but any other php pages I have break - any help greatly appreciated!

RewriteRule /(.*)\?(.*)$ /index.php\?q=$1&$2 [I,L]
Coordinator
Dec 6, 2011 at 9:34 PM

First, It's better to NOT use RewriteBase the way you have it.   Read the documentation for an explanation of why.  However, this is not the source of your immediate problem.

The rule you have in your "following rules" includes an un-escaped question mark.  That's probably wrong. 

I don't know what you mean by "the other php pages break."  The way to determine what is happening in the rewrite engine is to turn on logging, and examine the IIRF log file for a request that is "not working".  Read the documentation to learn how to do this.