Solved

Apache mod_rewrite and wordpress RSS feed

Posted on 2009-04-10
3
651 Views
Last Modified: 2012-05-06
I'm changing my blog to wordpress and and don't want to lose the people that already have my rss feed. The old link to my RSS feed was /blog/index.cfm?event=showBlogRss  The new one is /tech/feed/

I've done many URL rewrites in the past but can't find what I'm doing wrong here or if this is a problem with WordPress itself. The rewrite rull I'm putting in my .htacces file is below.

When I execute the code wordpress displays a page not found error.

Any insights on this?
RewriteCond %{QUERY_STRING} ^event=showBlogRss$ 

RewriteRule ^blog/index\.cfm$ /tech/feed? [NC,L]

Open in new window

0
Comment
Question by:lostlinkpr
  • 2
3 Comments
 
LVL 27

Accepted Solution

by:
caterham_www earned 210 total points
ID: 24121486
> if this is a problem with WordPress itself

WP analyzes the requested URI, that is and remains /blog/index.cfm?event=showBlogRss. Send an external redirect rather then using an internal rewrite:
RewriteCond %{QUERY_STRING} ^event=showBlogRss$ 

RewriteRule ^blog/index\.cfm$ /tech/feed? [R=301,NC,L]

Open in new window

0
 
LVL 1

Author Comment

by:lostlinkpr
ID: 24122458
You're right, that's, however, because I was pointing to the permalink which is a rewrite itself. So If I point to the link directly as shown below it seems to work.

However on some rss readers (i.e. firefox works just fine but OMEA reader fails) I get an error saying "the address does not point to a valid html or xml" this is with or without a rewrite so it seems like a Wordpress RSS problem. Anyways your solution with the 301 seems like it would work with the readers too so as soon as I can test it I'll give you the points.

thank you!
RewriteCond %{QUERY_STRING} ^event=showBlogRss$ 

RewriteRule ^blog/index\.cfm$ /tech/?feed=rss2 [NC,L]

Open in new window

0
 
LVL 1

Author Comment

by:lostlinkpr
ID: 24122877
Solved!

The problem with the invalid XML was my fault as I had once edited one of the php files (index.php) and left extra characters at the bottom of the file causing extra lines when the XML was created making it invalid.  Having said that both solutions work (external or internal redirect).  Since both work, I prefer the external redirect as Caterham suggested because it tells the search engines and RSS feeders that the location of the RSS has changed permanently. Below is a code snippet using Caterham solution pointing to the direct WP link instead of the permalink.

Thanks for the help!
RewriteCond %{QUERY_STRING} ^event=showBlogRss$ 

RewriteRule ^blog/index\.cfm$ /tech/?feed=rss2 [R=301,NC,L]

Open in new window

0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
WooCommerce Sort by Date 4 34
listing all functions in JavaScript 19 179
Apache/PHP: Cannot make phpinfo() and phpmyadmin work 4 37
CSS z-index issue 3 22
I annotated my article on ransomware somewhat extensively, but I keep adding new references and wanted to put a link to the reference library.  Despite all the reference tools I have on hand, it was not easy to find a way to do this easily. I finall…
If you are a web developer, you would be aware of the <iframe> tag in HTML. The <iframe> stands for inline frame and is used to embed another document within the current HTML document. The embedded document could be even another website.
The purpose of this video is to demonstrate how to properly insert a Vimeo Video into a WordPress site or Blog. This will be demonstrated using a Windows 8 PC. Go to your WordPress login page. This will look like the following: mywebsite.com/wp…
The purpose of this video is to demonstrate how to Import and export files in WordPress. This will be demonstrated using a Windows 8 PC. Go to your WordPress login page. This will look like the following: mywebsite.com/wp-login.php : Click on Too…

896 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now