1

I had an issue a while ago in this post: 301 redirect in htaccess

Everything is good but now on another project I'm working on, it's actually the reverse of that.

So basically, I need to to go from:

site.com/blah-blah/

To this:

site.com/blah-blah.123 (the id of the article)

The problem is I don't know what the ID of the article is unless I run a PHP query which I have no idea how to do with htaccess. Is this possible?

The solution in the other post is this:

RewriteRule ^industry/([a-zA-Z0-9-]+).([0-9]+)/$ /$1/ [R=301]

But that wouldn't work if I reversed it. Any ideas? Thanks.

Community
  • 1
  • 1
  • 1
    .htaccess runs way before PHP is invoked so noway you can use id generated from PHP code – anubhava Jun 13 '15 at 12:34
  • 1
    Indeed - that is correct. As such, you need to get WordPress to do the redirect for you. I'm no WordPress guru, but there's a slight chance that if you change the permalink structure to `%postname%.%post_id%`, it might just do the redirect - but I could be wrong. – Mike Rockétt Jun 13 '15 at 13:57
  • You're right. I tried a bunch of things but it just doesn't seem possible. Ah well, thanks for the replies anyway. –  Jun 14 '15 at 20:47

0 Answers0