Wordpress htaccess help

Discussion in 'WordPress' started by sarahturned, Oct 16, 2009.

  1. #1
    I noticed this code in my htaccess file. I didn't add it there.

    What exactly does this do and how did it get there?

    # BEGIN WordPress
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
    </IfModule>

    # END WordPress
     
    sarahturned, Oct 16, 2009 IP
  2. tonks

    tonks Peon

    Messages:
    50
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Its fine,

    I'm guessing you set your permalinks to /%postname%/
    Therefore that code that you presented has been entered into the .htaccess file for it to work.

    No biggie =)
     
    tonks, Oct 16, 2009 IP
  3. Dan Schulz

    Dan Schulz Peon

    Messages:
    6,032
    Likes Received:
    437
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Pretty much. However, WordPress will still have a canonical URI issue that needs to be dealt with. Change the domain name and TLD to match your own, and put this at the VERY TOP of your .htaccess file:

    
    Options +FollowSymLinks
    RewriteCond %{THE_REQUEST} ^.*/index.html
    RewriteRule ^(.*)index.html$ http://www.yourdomain.tld/$1 [R=301,L]
    RewriteCond %{THE_REQUEST} ^.*/index.php
    RewriteRule ^(.*)index.php$ http://www.yourdomain.tld/$1 [R=301,L]
    
    # Redirects non-www version to www. version
    RewriteCond %{HTTP_HOST} ^yourdomain\.tld [NC] 
    RewriteRule ^(.*) http://www.yourdomain.tld/$1 [R=301,L]
    
    Code (markup):
    Note: yourdomain and tld are PLACEHOLDERS.

    (Why the index.html redirect? WordPress will throw a 404 status code if you don't have it.)
     
    Dan Schulz, Oct 16, 2009 IP
  4. sarahturned

    sarahturned Peon

    Messages:
    268
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Is this really necessary, I am using All In One SEO, doesn't that correctly resolve the issue of cannonical problems.
     
    sarahturned, Oct 16, 2009 IP
  5. Dan Schulz

    Dan Schulz Peon

    Messages:
    6,032
    Likes Received:
    437
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Yes, it's necessary. I found that out the hard way when I redesigned my own Web site, www.dan-schulz.com -- and I'm also using the All In One SEO Pack (among others).
     
    Dan Schulz, Oct 16, 2009 IP