I'm trying to have SEO friendly URLs for my wordpress blog, while still having the flexibility to change a post's title at will.
My permalink structure would be like this:
%post_id%/%postname%
However, I'd like wordpress to just consider the %post_id% from the URL when looking for the appropriate post (sort of like here on stackoverflow)
For example:
http://stackoverflow.com/users/810/crossbrowser is the same as http://stackoverflow.com/users/810/hello-world
I'd like all of these to point to the same post, the one with id 345:
http://myblog.com/345/the-name-of-the-post
http://myblog.com/345/any-text
http://myblog.com/345
The documentation mentions something that seems like what I'm trying to do: Long permalinks, but I couldn't get it to work.
Here's my .htaccess file:
RewriteEngine on
RewriteBase /
# Let wordpress use pretty permalinks
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
# From the example in the documentation
#RewriteRule /post/([0-9]+)?/?([0-9]+)?/?$ /index.php?p=$1&page=$2 [QSA]
UPDATE
I keep trying this RewriteRule in this online regular expression testing tool, but it doesn't work when I put it in my .htaccess (just after RewriteBase):
RewriteRule ^([0-9]+)/?([a-zA-Z0-9\-]+)/?$ index.php?p=$1 [QSA]