Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
#1 2006-06-21 23:25:44
- joeamerica
- Member
- Registered: 2006-06-18
- Posts: 10
Migrating feeds from WP. Need some help with htaccess.
Hello all, I’m almost finished migrating a site from WP, but have one final issue: redirecting the rss feed.
I need to redirect mysite.com/?feed=rss2 to mysite.com/rss
The rule that isn’t working is:<pre><code>RewriteRule ^\?feed=rss2(.*)$ rss [R,L]
</code></pre>
My .htaccess file is below. (the “ifModule mod_rewrite.c tags” are in my .htaccess file, too. they got stripped out of the code below. the other additional lines redirect my old permalinks…)
<pre><code>
#DirectoryIndex index.php index.html
#Options +FollowSymLinks
RewriteBase /
<IfModule mod_rewrite.c> RewriteEngine On RewriteRule ^archives/(.*)$ blog/ [R,L] RewriteRule ^2006/(.*)$ blog/$1 [R,L] RewriteRule ^2005/(.*)$ blog/$1 [R,L] RewriteRule ^posts/blog/(.+)/$ blog/\?c=$1 [R,L] RewriteRule ^\?feed=rss2(.*)$ rss [R,L] RewriteCond %{REQUEST_FILENAME} -f [OR] RewriteCond %{REQUEST_FILENAME} -d RewriteRule ^(.+) – [PT,L]
RewriteRule ^(.*) index.php </IfModule>#php_value register_globals 0
</code></pre>
suggestions?
Offline
#2 2006-06-22 01:23:26
- Mary
- Sock Enthusiast
- Registered: 2004-06-27
- Posts: 6,236
Re: Migrating feeds from WP. Need some help with htaccess.
#DirectoryIndex index.php index.html
#Options +FollowSymLinks
RewriteEngine On
RewriteBase /
RewriteCond %{QUERY_STRING} feed=rss2
RewriteRule ^(.*)$ rss [R=301,L]
RewriteRule ^posts/blog/(.+)/$ blog/\?c=$1 [R=301,L]
RewriteRule ^archives/(.*)$ blog/ [R=301,L]
RewriteRule ^2006/(.*)$ blog/$1 [R=301,L]
RewriteRule ^2005/(.*)$ blog/$1 [R=301,L]
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^(.+) - [PT,L]
RewriteRule ^(.*) index.php
#php_value register_globals 0
I also added 301 to your redirects, so that Google, etc will know these are permanent redirects, rather than temporary.
Offline
#3 2006-06-22 18:03:51
- joeamerica
- Member
- Registered: 2006-06-18
- Posts: 10
Re: Migrating feeds from WP. Need some help with htaccess.
Thanks, Mary. I think we’re halfway there. When I try to load <code>mysite.com/?feed=rss2</code> i get an error. The address that comes up is:
<code>mysite.com/rss?feed=rss2</code>. It seems it gets redirected, but doesn’t clear the query string. Hmm…
Offline
#4 2006-06-22 18:14:07
- joeamerica
- Member
- Registered: 2006-06-18
- Posts: 10
Re: Migrating feeds from WP. Need some help with htaccess.
Got it. From the apache docs
When you want to erase an existing query string, end the substitution string with just the question mark.
The rewrite rule now reads
<pre><code>RewriteCond %{QUERY_STRING} feed=rss2
RewriteRule ^(.*)$ rss? [R=301,L]
</code></pre>
Onward!
Edit typos…
Last edited by joeamerica (2006-06-22 18:15:51)
Offline