Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
[RESOLVED] Redirect URLs from old site to new txp installation
We’ve got an old site that now runs Textpattern. The latter used ASP.NET and the URL scheme looked something like this:
http://www.site.com/a.aspx?article_id=14077&page=1
I was hoping that the following regex would be able to strip out all but the id number (which RegExhibit confirmed when I tested the syntax):
^a\.aspx\?article_id=(.*)&(.*)$
The result should be:
http://www.site.com/article/14077
so I tried this in .htaccess
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^(.+) - [PT,L]
RewriteRule ^(.*) index.php
RewriteRule ^a\.aspx\?article_id=(.*)&(.*) /article/$2 [R=301,L]
</IfModule>
(The last RewriteRule is the one added by me, the rest comes default with Textpattern)
Yet, RewriteLog tells me that there was no match in the pattern. It worked when I tried it in RegExhibit, but mod_rewrite does not approve. How come?
Last edited by frippz (2007-10-24 09:59:22)
Offline
#2 2007-10-24 09:52:53
- Mary
- Sock Enthusiast
- Registered: 2004-06-27
- Posts: 6,236
Re: [RESOLVED] Redirect URLs from old site to new txp installation
Order of rewrite rules matters.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^a\.aspx\?article_id=(\d*)(.*)? /article/$1 [R=301,L]
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^(.+) - [PT,L]
RewriteRule ^(.*) index.php
</IfModule>
Offline
Offline