Mod_rewrite URL to a query string to pass to WordPress.
-
I’ve done a lot of testing and have got all the rules I need working in a non-Wordpress environment but still using the default htaccess.
I have rewrite rules translating the last “folder” to a query string and I’m able to echo the
$_GET['querystring']
. This is just some ‘querystring’ for something else has nothing to do with WordPress./page/id5555/
to/page/?querystring=id5555
Although my theme is echoing this query string, WordPress is still interpreting it as looking for
/page/id5555/
.<IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteRule ^page/\b([A-z][A-z]\d{4})\b/?$ /page/?querystring=$2 [L] </IfModule>
So at this point the new URL is
/page/?querystring=id5555
Which next comes…# BEGIN WordPress <IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L] </IfModule> # END WordPress
but WordPress tries to interpret ‘/page/id5555/’ instead. Though I am able to echo
$_GET['querystring']
.
- The topic ‘Mod_rewrite URL to a query string to pass to WordPress.’ is closed to new replies.