How to do a 301 Redirect in an .htaccess file

The server response code (i.e. 301 v.s 302) can have a significant impact to the crawlers and bots that crawl your site. I wrote about that in some detail in an article titled, “What is the difference between 301 and 302 redirects in SEO?

But the purpose of this article to simple outline how to add a 301 redirect to your .htaccess file, not explain server response codes.

Here is the 301 redirect code of the .htaccess file:

Redirect 301 /oldpage https://www.domain.com/NewPageURL

You would replace “oldpage” with the relative path to the page that you are wanted to direct traffic from and then replace “https://www.domain.com/NewPageURL” with the absolute path of the URL that you are wanting to send that traffic to.

.htaccess Redirect Tips

  1. The spacing is important
  2. The “/” before the relative path is important
  3. 1 redirect command per line

How to add the Featured Image to WordPress RSS Feed

Problem:

By default, WordPress does not include the featured image in the RSS feed of your posts.

Solution:

Add this snippet of code to your functions.php or a mu-plugin. The below code uses the ‘large’ format image of the file saved as the featured image for the post.

function featuredIMGtoRSS($content) {
global $post;
if ( has_post_thumbnail( $post->ID ) ){
$content = '<div>' . get_the_post_thumbnail( $post->ID, 'large', array( 'style' => 'margin-bottom: 15px;' ) ) . '</div>' . $content;
}
return $content;
}
 
add_filter('the_excerpt_rss', 'featuredIMGtoRSS');
add_filter('the_content_feed', 'featuredIMGtoRSS');

Resolving Generic “HTTP Error” in the WordPress Media Uploader

Over time I have built, edited, and contributed to hundreds of WordPress websites. But it wasn’t until an odd scenario of events this year that I ran into a rogue, yet vague error in WordPress “HTTP error” …

The Generic “HTTP error” during a WordPress Upload

wordpress upload http error

The WordPress HTTP Error Upload Problem:

  1. Uploading images caused a generic”HTTP Error” in the WordPress Upload.
  2. The raw files was getting uploaded to the WordPress website but WordPress wasn’t crunching the image or producing any of the alternate image sizes.
    1. The thumbnails in the Media Gallery were also missing
  3. No PHP error was being logged in the error_log file

Fixing the WordPress HTTP Error

After some research and review I found a plugin that was shared on github that resolves a conflict. The underlying issue is that some website hosts and WordPress have a conflict on the WP Image Editor class. This seems to be a rare issue. I have only run into this on one website.

The solution was to apply to create this WordPress plugin and add it to the WordPress having the issue. Once the plugin was activated, the HTTP error was gone on the next upload attempt. WordPress media uploads returned to the proper crunching and optimization process.

Resources