Note that there are some explanatory texts on larger screens.

plurals
  1. POWordpress, .htaccess and mod_rewrite: how can I add redirection rules?
    text
    copied!<p>At the moment, I have a standard installation of Wordpress 3.0, and the .htaccess file looks like this:</p> <pre><code>&lt;IfModule mod_rewrite.c&gt; RewriteEngine On RewriteBase / RewriteRule ^index\.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L] &lt;/IfModule&gt; </code></pre> <p>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 <code>/event/123/</code> should pull the details for event #123 from my database, without the page existing in Wordpress.</p> <p>I was thinking I could create a "generic event" page (eg. <code>/event/generic/</code>) in Wordpress and have it take a parameter, such as:</p> <pre><code>RewriteRule ^event/(\d+)/$ /event/generic/?q=$1 [L] </code></pre> <p>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? </p> <p>The only other solution I've thought of would be to hack 404.php within the theme.</p> <p><strong>Update</strong></p> <p>My <code>.htaccess</code> looks like this:</p> <pre><code>&lt;IfModule mod_rewrite.c&gt; 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] &lt;/IfModule&gt; </code></pre> <p>If I then go to <code>/eventtest/testing/</code>, then:</p> <pre><code>$_SERVER['REQUEST_URI'] is /eventtest/testing/ $_SERVER['REDIRECT_URL'] is /events/event-single/ </code></pre> <p>The <code>/events/event-single/</code> page exists in Wordpress, but if I go to <code>/eventtest/testing/</code>, I get a 404 page.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload