Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
[SOLVED] Changed article section, using .htaccess to redirect
I’ve changed the article section for a bunch of old articles. I am now, inevitably dealing with the sitemap and search engine 404 error fallout. Assume I’m switching articles from this format:
http://example.com/old/article-title
…to this:
http://example.com/new/article-title
My .htaccess
regex voodoo isn’t as good as it used to be. I’m using the following as a base:
RewriteEngine on
RewriteRule ^old(/.*)?$ /new$1 [L,R=301]
Somewhat predictably, it’s not working. My humble request is two-fold:
i) What am I doing wrong with my code above?
ii) Where is the best place for the code to be situated, assuming a stock .htaccess
with the standard Rewrite rules?
As ever, thank you in advance for pointers and advice.
Last edited by gaekwad (2013-10-17 15:35:03)
Offline
#2 2013-10-17 15:27:19
- alivato
- Member
- Registered: 2011-03-31
- Posts: 151
Re: [SOLVED] Changed article section, using .htaccess to redirect
Try this
RedirectMatch 301 ^/old/(.*)$ http://www.example.com/new/$1
Offline
Re: [SOLVED] Changed article section, using .htaccess to redirect
Oh, smart – thanks, alivato.
Offline
Re: [SOLVED] Changed article section, using .htaccess to redirect
OK, solved: my syntax was correct, but the placement was wrong. Having it as the first condition after RewriteEngine On
makes it work; I had it too low in the file and it was being shoved out.
Thanks again to alivato for a potentially prettier solution.
Offline