I am been plucking out my hairs since last few days trying to solve this problem:

I want to convert my urls from format




to start with I added following rules to my .htaccess

RewriteRule ^prodsearch/(.*)/(.*)-(.*)$ prodsearch/$1/$2+$3 [L]
RewriteCond %{REQUEST_URI} !^prodsearch/(.*?)/(.*)\-(.*)
RewriteRule ^prodsearch/(.*)/(.*)$ index.php?tag=$2&cat=$1 [R,QSA,L]

Here rule1 recursively replaces all '-' between tags by '+' and rule2 does the actual rewrite once there are no more '-' left between tags (checked by RewriteCond)

These rules actually work, but the problem is they redirect (with url change) to new url pattern, I don't want an explicit redirection. On removing 'R' flag from last rule, the whole thing stops working and I start getting 404 page in my wordpress install.

Can some one explain why this is happening and how to do this without explicit redirection.

Also I tried including these rules into wordpress, hoping when called by wordpress rules may work without redirection. I used following add_rewrite_rule() calls:


Now wordpress detects my first rule as external rule and flushes it to .htaccess file, this screws my execution order, now first rule 2 gets evaluated first(being part of internal wordpress rewrite rule set) and rule 1 gets executed later, hence again 404 page.

Is it possible to tell wordpress not to consider my first rule as a external rule and not to flush it to .htaccess, or to evaluate the external rewrite rule before internal wordpress rewrite rules.

Finally can anyone help me make this kind of rewrite work? Thanks a lot.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.