I’m using WordPress 3.4.1 with permalinks turned on. In my .htaccess, I have the following code:
<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 also want to set up a custom rewrite (NOT a redirect) so that when a user goes to this URL:
http://example.com/about/video-center/youtubeID/title-slug/
It gets internally rewritten as:
http://example.com/about/video-center/
Right now, the first URL 404s.
I tried adding this rule to my .htaccess after the RewriteBase / line:
RewriteRule ^about/video-center/(.+)$ /about/video-center/ [NC,L]
Which does nothing (I still get a 404). If I add a R to the flags, then it redirects and /about/video-center/ loads just fine, which leads me to believe the rule is matching and rewriting appropriately.
My theory is that the rewrite works fine… but when WP’s rewrite rules take effect, any custom rewrite rules I have are overridden — that even though it’s rewriting internally, WP is still trying to handle the URL that’s in the address bar.
I don’t know how to get around this and make my custom rewrites work with WordPress.
Now, I realize it might not be possible to achieve the result I want from .htaccess alone, and that a plugin, or some custom code in my Theme’s functions.php might be needed to solve this problem. I’m open to whatever solution gets this done.
Spent too much time trying to find a solution for this, I’m just going to use hashes instead:
http://example.com/about/video-center/#youtubeID/title-slug/