Mod Rewrite for WordPress Permalinks

The .htaccess is a distributed configuration file, and is how Apache handles configuration changes on a per-directory basis.

WordPress uses this file to manipulate how Apache serves files from its root directory, and subdirectories thereof. Most notably, WP modifies this file to be able to handle pretty permalinks.

You can use the following WordPress default .htaccess codes for your site, depending on your usage.

To do so, you simply have to nagivate to the web root directory of the domain in question to create a file named .htaccess and place the codes inside.

 

  1. Basic WPNon-Temporary URL# 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

    Temporary URL

  2. Multisite (wordpress 3.5 and up)
    • Subfolder ExampleRewriteEngine On
      RewriteBase /
      RewriteRule ^index\.php$ – [L]# add a trailing slash to /wp-admin
      RewriteRule ^([_0-9a-zA-Z-]+/)?wp-admin$ $1wp-admin/ [R=301,L]

      RewriteCond %{REQUEST_FILENAME} -f [OR]
      RewriteCond %{REQUEST_FILENAME} -d
      RewriteRule ^ – [L]
      RewriteRule ^([_0-9a-zA-Z-]+/)?(wp-(content|admin|includes).*) $2 [L]
      RewriteRule ^([_0-9a-zA-Z-]+/)?(.*\.php)$ $2 [L]
      RewriteRule . index.php [L]

    • Sub Domain ExampleRewriteEngine On
      RewriteBase /
      RewriteRule ^index\.php$ – [L]# add a trailing slash to /wp-admin
      RewriteRule ^wp-admin$ wp-admin/ [R=301,L]

      RewriteCond %{REQUEST_FILENAME} -f [OR]
      RewriteCond %{REQUEST_FILENAME} -d
      RewriteRule ^ – [L]
      RewriteRule ^(wp-(content|admin|includes).*) $1 [L]
      RewriteRule ^(.*\.php)$ $1 [L]
      RewriteRule . index.php [L]

  3. Multisite (wordpress 3.4 and below)
    • Sub Folder Example# BEGIN WordPress
      RewriteEngine On
      RewriteBase /
      RewriteRule ^index\.php$ – [L]# uploaded files
      RewriteRule ^([_0-9a-zA-Z-]+/)?files/(.+) wp-includes/ms-files.php?file=$2 [L]

      # add a trailing slash to /wp-admin
      RewriteRule ^([_0-9a-zA-Z-]+/)?wp-admin$ $1wp-admin/ [R=301,L]

      RewriteCond %{REQUEST_FILENAME} -f [OR]
      RewriteCond %{REQUEST_FILENAME} -d
      RewriteRule ^ – [L]
      RewriteRule  ^[_0-9a-zA-Z-]+/(wp-(content|admin|includes).*) $1 [L]
      RewriteRule  ^[_0-9a-zA-Z-]+/(.*\.php)$ $1 [L]
      RewriteRule . index.php [L]
      # END WordPress

    • Sub Domain Example# BEGIN WordPress
      RewriteEngine On
      RewriteBase /
      RewriteRule ^index\.php$ – [L]# uploaded files
      RewriteRule ^files/(.+) wp-includes/ms-files.php?file=$1 [L]

      RewriteCond %{REQUEST_FILENAME} -f [OR]
      RewriteCond %{REQUEST_FILENAME} -d
      RewriteRule ^ – [L]
      RewriteRule . index.php [L]
      # END WordPress

If you have further questions, please do not hesitate to contact our support team.

Mod Rewrite for WordPress Permalinks

(Visited 105 times, 1 visits today)

Leave A Comment?