I am trying to pass a variable from a URL to PHP using mod_rewrite while maintaining standard WordPress functionality.
Here's my mod_rewrite rules:
RewriteEngine On
RewriteBase /
RewriteRule ^(\w+)/$ /index.php?state=$1 [L]
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
When I go to this URL: http://epiclasers.com/arizona/
It is obviously being handled by index.php (because the theme is being loaded) and the state variable is being passed to PHP. but I am having trouble getting the home page content to be displayed - instead it is showing 404 "page not found" content.
Can someone shed some light as to why this is happening?
UPDATE:
When I redirect using the R flag, it works as it should:
RewriteRule ^(\w+)/$ /index.php?state=$1 [R,L]
and the home page is served: http://epiclasers.com/?state=arizona
It seems that WP is grabbing the URL using $_SERVER['REQUEST_URI'] to process requests/queries - and WP is getting confused by the /arizona/ in the URL?
Let's just assume that mod_rewrite is functioning correctly. Does anyone know how to customize WordPress to ignore "/arizona/" in the URL?