WordPress: Custom Rewrite Rules Print

  • 37

It may be the case that custom rewrite rules you've made produce 404 errors.

  1. Open/edit your .htaccess file. Look for code that looks like this:
    # BEGIN WordPress
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
    </IfModule>
    # END WordPress
  2. List paths that should not obey WordPress rewrites in the RewriteCond %{REQUEST_URI} !^/(path1|path2|path3) [NC]. It should look like this:

    # BEGIN WordPress
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d

    RewriteCond %{REQUEST_URI} !^/(abc|xxx|events/go-to-town) [NC]

    RewriteRule . /index.php [L]

    RewriteRule ^abc/$ "http://wordpress.com/" [R=301,L]
    RewriteRule ^xxx/$ "http://support.hostgator.com/" [R=301,L]
    RewriteRule ^events/go-to-town/$ "http://secure.hostgator.com/~affiliat/cgi-bin/affiliates/clickthru.cgi?id=whatever" [R=301,L]

    </IfModule>
    # END WordPress

  3. You may now add your custom rewrite rules above the line that begins with </IfModule>,

 





Was this answer helpful?

« Back