How To Disable Directory Browsing in WordPress

Directory browsing is enabled by default in most web hosts. This is very insecure as anyone can browse through your web directories and gather the information regarding the plugins and themes you are using.

This information, in turn, is used to attack your site using the vulnerabilities found in your plugins, themes, and other files.

So, let me show you how to disable directory browsing in WordPress to protect your WordPress site and keep sneaky eyes off your server directories.

In this article, I’m going to show the process in two different methods, i.e. using a .htaccess rule and from the cPanel options. Follow the procedure that you are most comfortable with.

Disable Directory Browsing from cPanel

The first method to disable directory browsing in WordPress is to use the built-in options in the cPanel. If you don’t have access to the cPanel then follow the .htaccess method show below.

1. To disable directory browsing in the cPanel, login to your cPanel and click on the link “Index Manager” appearing in the “Advanced” section.

disable-directory-browsing-index-manager

2. The above action will open the directory selection window. Select the “Web Root” option and click on the “Go” button.

disable-directory-browsing-web-root

3. This will take you to the index manager, here select the folder you want to disable directory listing. Generally, you have to select “public_html” or “www” directory.

disable-directory-browsing-select-folder

4. Here in this window, select the radio button “No Indexing” and click on the button “Save” to save changes.

disable-directory-browsing-select-no-indexing

5. That’s it. You have disabled directory browsing in WordPress.

Disable Directory Browsing Using .htaccess Rule

Disabling directory browsing using .htaccess rule is really simple. All you have to do is to edit the file to add a rule. Do backup the file before editing it.

1. To start off, log into your FTP account. You can use any of the free FTP clients like CyberDuck or FileZilla.

2. Once logged in, navigate the root directory, find and open the “.htaccess” file. Since the .htaccess is a hidden file, make sure that you have enabled your FTP client to show hidden files.

3. After opening the file, add the below rule on top of the .htaccess file.

# Disable Directory Browsing
Options -Indexes

Once you have added, just save and re-upload the file. That’s all there is to do. You have successfully disabled the directory browsing in your WordPress site.

That’s all there is to do. it is that simple to disable directory browsing in WordPress using the cPanel and a simple .htaccess rule.

Hopefully that helps and do comment below of you face any problems while disabling directory browsing in WordPress.

How to Redirect Non-WWW URLs to WWW in WordPress

In the last article, I’ve shared how you can redirect www URLs to non-www URLs in WordPress. This is pretty important when you want a non-www domain to be your base domain. However, if you want the www subdomain to be your root domain then you need to create proper 301 redirects to your base domain.

So, if you’ve just created a WordPress site or if there are no proper www redirects to your base domain then you should consider redirecting non-www URLs to www URLs.

What Happens in Case of No Proper Redirection?

Here are some issues that you may face when there are no proper redirects to your base domain.

  • Search engines will see your non-www domain and www domain as separate entities.
  • Since the same content (or 404 error in some cases) is shown on both the pages, search engines may see it as the duplicate content.
  • No proper redirection to your base domain may confuse search engines.
  • Can also disrupt the link flow when websites link to your non-www domain when in fact you prefer www domain.

In case you are wondering, here is how to redirect non-www URLs to www URLs in WordPress.

Redirect Non-WWW URLs to WWW from cPanel

Using the cPanel to redirect non-www URLs to www URLs is one of the easiest ways.

To start off, log into your web host’s cPanel. Once you are here, find the Domains section and then select the option “Redirects.”

redirect-non-www-to-www-cpanel-redirects

The above action will open the Redirects page where you can manage all your redirections. Here, configure the settings as detailed below.

  1. From the drop-down menu next to “Type,” select the option “Permanent (301).”
  2. Here on the next line, select your domain from the drop-down menu.
  3. On the next line, enter your domain name as http://www.example.com. Of course, replace example.com with your actual domain name.
  4. Now, select the radio button “Do not redirect www” in the next line.
  5. After selecting the radio button, click on the button “Add” to add the redirect.

redirect-non-www-to-www-configure-cpanel-www-redirect-settings

That’s all there is to do. From this point forward, all your non-www URLs will be redirected to www URLs. For instance, if a user or search engine tries to access example.com, they will be redirected to www.example.com.

Redirect Non-WWW URLs to WWW Using .htaccess

Note: before editing the .htaccess file, make a backup of it. It helps you in restoring the file if needed.

If you don’t have access to the cPanel or if you just want to use a simple .htaccess rule then you can do that too.

To start off, log into your website’s FTP client, navigate to the root folder, find the .htaccess file and open it. If you cannot see the file, configure your FTP client to show hidden files.

redirect-non-www-to-www-open-htaccess-file

After opening the .htaccess file, copy the below code and paste it on the top of the file, save it and then reupload it. Don’t forget to replace example.com with your actual domain name.

#Redirect non-www URLs to www URLs in WordPress
RewriteEngine On
RewriteCond %{HTTP_HOST} ^example.com [NC]
RewriteRule ^(.*)$ http://www.example.com/$1 [L,R=301]

That’s all there is to do. With the new .htaccess rule, you are successfully redirecting non-www URLs to www URLs.

Hope that helps and do comment below sharing your thoughts and experiences about using the above methods to redirect non-www URLs to www URLs in WordPress.

How to Redirect WWW URLs to Non-WWW in WordPress

When you create a website or blog, it is very important that you optimize your site for the search engine. One of the things that you should do to improve your SEO is to have proper 301 redirects to your base domain. What I mean to say is that you must choose between using WWW subdomain or not using it for your base domain.

Traditionally, most people prefer using WWW subdomain as their base or root domain. In fact, Bloggersignal uses the www subdomain.

However, if you don’t want to use the WWW subdomain then it is important that you create proper redirects to your non-WWW base domain.

What Happens in Case of No Proper Redirection?

Here are some issues that you may face when there are no proper redirects to your base domain.

  • Search engines will see your non-www domain and www domain as separate entities.
  • Since the same content (or 404 error in some cases) is shown on both the pages, search engines may see it as the duplicate content.
  • No proper redirection to your base domain may confuse search engines.
  • Can also disrupt the link flow when websites link to your www domain when in fact you prefer non-www domain.

So without further ado, here is how to redirect WWW URLs to non-WWW in WordPress.

Also read: how to stop WordPress from guessing URLs and redirecting users

Redirect WWW URLs to Non-WWW from cPanel

Most web hosts provide cPanel to easily manage your website. Fortunately, you can use the same cPanel to redirect WWW URLs to non-WWW URLs.

To start off, log into your cPanel, find the Domains section then click on the link “Redirects.”

redirect-www-to-non-www-cpanel-redirects

This open the Redirect page. Here, configure the settings as shown below.

  1. Select the option “Permanent (301)” from the drop-down menu next to “Type.”
  2. Select your domain name from the drop-down menu in the next line.
  3. Enter your domain name without the www subdomain the next line. Don’t forget to add the http:// prefix.
  4. Select the radio button “Only redirect with www.”

redirect-www-to-non-www-redirect-non-www-domain

Now, click on the button “Add” and you are good to go. From this point forward, every time a visitor or search engine tries to access www.example.com, they will be redirected to example.com.

Redirect WWW URLs to Non-WWW Using .htaccess

Note: before modifying the .htaccess file, create a backup of the file so that you can restore it if needed.

It is very easy to redirect WWW URLs to non-WWW URLs using a simple .htaccess rule. In fact, this method is pretty helpful if you don’t have standard backend interface like cPanel.

To start off, log into your website’s FTP account and then open the .htaccess file located in the root directory. If you can’t find the file, make sure that the FTP client is showing hidden files.

redirect-www-to-non-www-open-htaccess-file

Once the file has been opened, copy the below code and paste it on top of the file, save it and reupload it. Don’t forget to replace example.com with your actual domain.

#Redirect WWW URLs to Non-WWW in WordPress
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www.example.com [NC]
RewriteRule ^(.*)$ http://example.com/$1 [L,R=301]

That’s all there is to do. From this point forward, your www domain will redirect to non-www domain.

Alternative method: without hard coding the URL

If you look at the above code, you will see that the code is hard coded with your website URL. If you don’t want to hardcode the domain name then use the below code.

#Redirect WWW URLs to Non-WWW in WordPress without hard coding the URL
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ http://%1/$1 [R=301,L]

Both the code snippets will work the same. But, only use one. Don’t use both at the same time.

Hope that helps and do comment below sharing your thoughts and experiences about using the above methods to redirect WWW URLs to non-WWW URLs in WordPress.

Credits: thanks to Ben from Stackoverflow for the alternate .htaccess code.

How to Import .docx Documents in WordPress

Do you prefer writing your articles and blog posts on Microsoft Word instead of using WordPress? Want to import a .docx document straightaway and hassle free, instead of copying and pasting which usually breaks the formatting and messes up the whole document?

Well, look no further. In this article, I will show you how you can import .docx documents in WordPress with ease.

Why Write in Word Documents?

Most people who do blog and content writing tend to use Microsoft Word. There are a few reasons for this.

  • To easily use various types of formatting, tools, text effects, templates, etc.
  • Use the built-in spell check and thesaurus to organize their writing.
  • Save and organize them as individual files on their hard drive. This helps in terms of future reference and distribution if necessary.
  • Word documents come in handy in the scenario of guest blogging.
  • If you don’t want to give guest authors access to the admin area then they usually would have to send their posts in word documents (.docx files).
  • Maybe you already have some content saved in the form of word documents. It can be quite a difficult task to copy and paste from all those word documents.

On the contrary, the default visual editor provided in WordPress does not offer all these features. Considering all these situations, let’s take a look at how to properly import .docx document in WordPress without losing much of the formatting.

Import .docx Documents in WordPress

As the first step, you will need to install and activate a plugin called the Mammoth .docx Converter.

import-microsoft-document-to-wordpress-install-mammoth-plugin

After the plugin has been activated, you will need to create a new post or edit an existing one.

On the post edit screen, just below the post editor, you will find the Mammoth .docx converter meta box. You can use this to upload the .docx files.

Just click on the choose file button to select the .docx file of your choice from your computer.

import-microsoft-document-to-wordpress-upload-docx-file

Upon selecting the .docx file, the plugin will give you three types of views for the document that you have uploaded. The Visual tab will show you how the document will appear in WordPress.

import-microsoft-document-to-wordpress-visual-view

You will immediately notice that the converter will ignore any styles that have been applied to the uploaded document. These include but not limited to text color, background color, padding, margins, border etc. Instead, it will allow your theme stylesheet to control the display of those styles that have been applied.

By clicking on the Raw HTML button you can view the uploaded document in HTML format. The HTML is automatically generated by the converter.

import-microsoft-document-to-wordpress-raw-html-view

Clicking on the Messages button will bring up any warnings or error messages that would have happened during the conversion.

import-microsoft-document-to-wordpress-warnings-and-errors

If the document in the Visual Tab looks satisfactory, proceed to click on the “Insert into editor” button.

import-microsoft-document-to-wordpress-click-button-insert-into-edit

The plugin will then insert the converted .docx document into the WordPress post editor. You can continue to work on the post or save it and publish or update it as needed.

import-microsoft-document-to-wordpress-file-imported

As of now, the plugin supports the following features.

  • Heading styles, like Heading 1, Heading 2, are converted into h1,h2 tags.
  • Lists are supported.
  • Tables are imported – but formatting like borders and cell colors are left out.
  • Plain HTML formatting options like Bold, Italic, Superscript, and Subscript etc.., are supported
  • Images that are embedded within the word document can be imported into WordPress.
  • All links in the document will stay intact.
  • Text boxes will be converted into plain paragraphs.

The plugin, however, does not make any changes or alterations to your original .docx word document. The document itself is not stored on your WordPress site.

Similarly to importing .docx documents in WordPress, you can also import PDF files, spreadsheets and other types of documents.

Hope that helps and feel free to post any thoughts, questions, or feedback regarding the tutorial on how to import .docx documents in WordPress.