301 redirect question

3 replies
  • WEB DESIGN
  • |
I've only worked a little with Apache servers so I want to double check what I've done. I've implemented a 301 redirect on a WP site. It appears to have worked correctly but like I said I just want to be sure.

The original htaccess file looks like this. Notice the begin and end Wordpress comment tags. So I'm thinking this is instruction specifically for Wordpress and my redirect shouldn't be included here. In fact I'm thinking the redirect should be before any instructions for Wordpress because they should be executed when the site is first called.


Code:
 
# BEGIN WordPress
 
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
 
# END WordPress
So to that end I put the redirect before the Wp section like so...


Code:
 
#301 Redirect
 
RewriteEngine On
RewriteCond %{HTTP_HOST} !^realhomebusiness.us$
RewriteRule (.*) http://realhomebusiness.us/$1 [R=301,L]
 
 
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
 
# END WordPress
This appears to have worked as intended, at least in my browser. I.E. and Firefox.

Does anyone else have experience using a 302 redirect with WP?
#301 #question #redirect
  • Profile picture of the author ChristineCobb
    If you have cPanel, you can use the redirect section to do this easily without touching the .htaccess file. If your theme doesn't have this functionality built in, there are also plugins that will do the same thing for a particular page.
    Signature
    Creating an Affiliate Tools Page Couldn't Get Any Easier. Find out how.

    Free Screencast Videos Resource Guide Here
    {{ DiscussionBoard.errors[3942690].message }}
    • Profile picture of the author ronc0011
      Originally Posted by chriscobb View Post

      If you have cPanel, you can use the redirect section to do this easily without touching the .htaccess file. If your theme doesn't have this functionality built in, there are also plugins that will do the same thing for a particular page.

      I looked at those options but decided to go with the 301 method because my purpose here is to deal with the whole canonicalization issue. I'm redirecting the www version to the non-www version. After reading over the info on cpanel and other options I decided the htaccess approach was probably the best and surest way to do this.

      Like I said I just wanted to double check my method.
      {{ DiscussionBoard.errors[3942788].message }}
  • Profile picture of the author gotwebservices
    Banned
    [DELETED]
    {{ DiscussionBoard.errors[3942898].message }}
    • Profile picture of the author ronc0011
      So what's the reason for this. It does appear to be working the way I have it. What's the advantage to doing it like you recommend.

      I'm just trying to get a better understanding of what's happening.
      {{ DiscussionBoard.errors[3945553].message }}

Trending Topics