Loading...

Knowledge Base

How To Set Up Mod Rewrite for WordPress Permalinks

Most of the pages in your WordPress website—including but not limited to—About Us page, Contact Us page, and blog posts don’t have their own website files. We tend to look for an about us file whenever https://yourdomain.com/aboutus link shows an error on a browser but can’t find any. This is because the permanent links (permalinks) are manipulated using a mod_rewrite module in the web hosting program. The rules and conditions are written via codes in .htaccess file.  This article covers:  

 

How To Generate .htaccess File via WordPress Dashboard

WordPress automatically writes these codes and creates the .htaccess file for you. Follow the steps below on how to do it in your WordPress dashboard.

  1. Log in to your WordPress dashboard via the link yourdomain.com/wp-admin (replace yourdomain.com with the domain of your website) or on any of the methods below depending on your web hosting plan.
     
     
  2. Click Settings on the menu bar at the left side of the page.

    Screenshot of VD WordPress Settings Tab

     
  3. Click Permalinks.

    Screenshot of VD WordPress Permalinks Option

     
  4. Click the radio button that corresponds to your preferred permalinks format. Skip this step if changes are not necessary.
  5. Click the Save Changes button.

    Screenshot of VD WordPress Save Changes to Permalinks

 

The .htaccess file is stored in your website’s directory that you can access via cPanel’s File Manager or via connecting to FTP.

 

How To Manually Setup Mod Rewrite for WordPress Permalinks

The .htaccess file can be manually created or edited if WordPress doesn’t automatically do it for you. Follow the steps below on how to set it up manually.

  1. In your website directory, look for a .htaccess file. If none is existing, create a website file with that file name.
     
    TIP:

     
  2. Copy the code based on the setup of your WordPress website on the hosting.

    Basic WP (default) – Single website with no redirections.
     
    # BEGIN WordPress
    
    RewriteEngine On
    RewriteEngine On
    RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
    RewriteBase /
    RewriteRule ^index\.php$ - [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
    
    # END WordPress


    Multisite for WordPress 3.5 and up

    Subfolder
     – Copy the codes in the box below if your website is in a subfolder with a URL format of http://yourdomain.com/store in which yourdomain.com is your website’s domain name and store is the subfolder name.
     
    RewriteEngine On
    RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
    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]

    Subdomain – Copy the codes in the box below if your website’s URL is a subdomain. An example of a subdomain is http://store.yourdomain.com
     
    RewriteEngine On
    RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
    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. Edit the .htaccess file via cPanel’s File Manager or FTP.

    Screenshot of VD WordPress WP Config Edit Button

     
  4. Click the Save Changes button on the text editor.

    Screenshot of VD WordPress htaccess Save Changes Button
     

Do not hesitate to contact our Singapore or Australia Support Team if you have further questions.

 

 

 

 

Did you find this article helpful?

 
* Your feedback is too short

Loading...