WordPress: Custom Rewrite Rules

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>,

 




  • 37 Users Found This Useful
Was this answer helpful?

Related Articles

How to make WordPress show as Secure in Google Chrome

In order to make your WordPress installation show as Secure in Google Chrome, you'll need ensure...

Temporary URLs in WordPress

To use your Temporary URL with a WordPress installation, you will need to edit the Windows Hosts...

WordPress Optimization

Optimizing your scripts can keep your server and website loading quickly for your visitors. These...

Changing the WordPress Directory

You may want to change the location of your WordPress blog after you have installed it. For...

Fixing the Internal Server Error in WordPress

There are a few possible causes of the 500 Internal Server Error. It is not always due to...