UPDATE
I tried using internal Wordpress chat. I need to make an address like this:
http:
sent to gallery.php with a variable containing artist-name .
I used these rules according to the Wordpress documentation:
// REWRITE RULES (per gallery) {{{ add_filter('rewrite_rules_array','wp_insertMyRewriteRules'); add_filter('query_vars','wp_insertMyRewriteQueryVars'); add_filter('init','flushRules'); // Remember to flush_rules() when adding rules function flushRules(){ global $wp_rewrite; $wp_rewrite->flush_rules(); } // Adding a new rule function wp_insertMyRewriteRules($rules) { $newrules = array(); $newrules['(galleria)/(.*)$'] = 'index.php?pagename=gallery&galleryname=$matches[2]'; return $newrules + $rules; } // Adding the id var so that WP recognizes it function wp_insertMyRewriteQueryVars($vars) { array_push($vars, 'galleryname'); return $vars; }
which is strange now, that in my local installation of Wordpress test, this works fine: the gallery page is called and the galleryname variable is galleryname . On the other hand, on the real site, the starting URL is accepted (as it does not go in 404), but it changes to http://example.com/gallery (I mean that it actually changes in the address bar of the browser) , and the variable is not defined in gallery.php .
Any idea what might cause this other behavior?
Alternatively, any other way that I could not think of that could achieve the same effect described in the first three lines is perfectly fine.
Old question
What I need to do is rewrite this address:
(1) http://localhost/wordpress/fake/text-value
to
(2) http:
Notes:
- reassignment should be transparent: the user always needs to see the address
(1) gallery - permalink to wordpress page, not real address
I basically need to first rewrite the address (change it) and then return it back to mod rewrite again (so that wordpress analyzes it in its own way).
Problems
if i just do
RewriteRule ^fake$ http://localhost/wordpress/gallery [L]
it works, but the address in the browser changes, which is not good if I do
RewriteRule ^fake$ /wordpress/gallery [L]
I get 404. I tried different flags instead of [L] , but to no avail. How can I make this work?
EDIT: full .htaccess
# BEGIN WordPress <IfModule mod_rewrite.c> RewriteEngine On RewriteRule ^fake$ /wordpress/gallery [R] RewriteBase /wordpress/ RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /wordpress/index.php [L] </IfModule> # END WordPress