At the moment, I have a standard installation of Wordpress 3.0, and the .htaccess file looks like this:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
I want to rewrite URLs so that I can provide some automatically generated pages, but keep it within the Wordpress theme. For example, going to /event/123/
should pull the details for event #123 from my database, without the page existing in Wordpress.
I was thinking I could create a "generic event" page (eg. /event/generic/
) in Wordpress and have it take a parameter, such as:
RewriteRule ^event/(\d+)/$ /event/generic/?q=$1 [L]
However, that doesn't seem to work, it just takes me to the Wordpress 404 page. I'm thinking that I might be asking a lot of Wordpress here, but surely it's possible?
The only other solution I've thought of would be to hack 404.php within the theme.
Update
My .htaccess
looks like this:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^eventtest/(\w+)/$ /events/event-single/ [L]
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
If I then go to /eventtest/testing/
, then:
$_SERVER['REQUEST_URI'] is /eventtest/testing/
$_SERVER['REDIRECT_URL'] is /events/event-single/
The /events/event-single/
page exists in Wordpress, but if I go to /eventtest/testing/
, I get a 404 page.