tags:

views:

28

answers:

1

want to rewrite urls like site.com/software to wp-content/themes/dir/software.php and something is not working.. Here's what I have:

RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
RewriteRule ^software wp-content/themes/dir/software.php [L]

Thanks!

A: 

Rewrite rules are processed in the order that they are encountered. In this case, every request is getting pushed to index.php before your software rule is encountered (assuming that software doesn't exist in the system as a directory or file). The [L] on the end of the first rule tells Apache to stop reading rules, so it doesn't even bother processing the next one.

Try this:

RewriteEngine On
RewriteBase /
RewriteRule ^software wp-content/themes/dir/software.php [L]        
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
zombat
thanks, that worked! one thing I don't understand is I did try changing the order of index and software, but I didn't go higher than Rewrite conditions.. What's the significance there? THANKS!
Jeff
`RewriteCond` directives only apply to the very next `RewriteRule` that gets encountered. If you had moved the "software" `RewriteRule` above the "index.php" rule, then the `RewriteCond` lines would have then applied only to the "software" rule, which isn't what you would have wanted.The reverse of that is that anything you put *under* the "index.php" rule won't be affected by the `RewriteCond` directives above the "index.php" rule.
zombat
got it, thanks!
Jeff
No problem, glad it's working.
zombat
another question if you be so kind..I'm setting up the google adwords and it's not meshing well with the mod_rewrite (getting the Invalid HTTP Response Code from adwords)The rule I use is RewriteRule ^([a-z]+)$ wp-content/themes/dir/$1.php [L].. I read that Google is adding an id to the end of the request.. could that be the problem?
Jeff