One place for hosting & domains

      Beginners

      Beginner’s Guide to the WordPress .htaccess File


      Keeping your site safe should be a top priority for every administrator. WordPress is a secure platform out of the box, but that doesn’t mean it’s impervious to attacks. Fortunately, even if you aren’t a security expert, you can use a file called .htaccess to harden your site’s security policies.

      .htaccess is a configuration file for the Apache web server, which serves many WordPress sites. It’s a powerful tool that helps safeguard your site and boost its performance through some minor tweaks to its code. By editing this file, you can ban users, create redirects, prevent attacks, and even deny access to specific parts of your site.

      An Introduction to the .htaccess File

      .htaccess is short for “HyperText Access.” It’s a configuration file that determines how Apache-based servers interact with your site. In simpler terms, .htaccess controls how files in a directory can be accessed. You can think of it as a guard for your site because it decides who to let in and what they’re allowed to do.

      By default, an .htaccess file is typically included in your WordPress installation. The main purpose of this file is to improve security and performance. Plus, it also enables you to override your web server’s settings.

      You’ll most likely find your .htaccess file in your site’s root directory. Since .htaccess applies to both its own directory and any subdirectories within that main folder, it impacts your entire WordPress site.

      It’s also worth noting that the .htaccess file does not have a file extension. The period at the start simply makes sure the file remains hidden.

      How to Edit Your WordPress .htaccess File

      Editing the .htaccess file is, in practice, as simple as editing any other text file. However, because this is a core file, making changes to it can have unintended consequences.

      For this reason, it’s vitally important that you back up your site before you begin, regardless of whether you’re a beginner or an experienced developer.

      When you’re ready to edit your .htaccess file, you can access it using Secure File Transfer Protocol (SFTP) or Secure Shell (SSH). You will find .htaccess in your site’s root directory:

      WordPress .htaccess file

      Open the file using your preferred text editor, such as TextEdit or Notepad. If the file hasn’t been edited before, you’ll see the following default information:

      WordPress .htaccess file

      It’s important not to add or change anything between the # BEGIN and # END tags. Instead, all new code should be added after this block.

      At this point, all you need to do is add your code and save the file. When you’re including multiple new functions, it’s best to save and test each one separately. If an error occurs, this will make it much easier to troubleshoot which change caused the problem.

      While almost all WordPress installations will already contain an .htaccess file, in some cases, you may need to create one. You can do this using a text editor of your choice, as long as you save it with the right file name: .htaccess with no extension.

      It’s also important to configure the file’s permission settings correctly. You can then upload .htaccess to your site’s root directory.

      9 Things You Can Do With Your WordPress .htaccess File

      Now that you’re familiar with the .htaccess file, it’s time to get up close and personal. We’re going to introduce a number of ways you can easily boost your site’s security and performance by editing this file.

      Simply use the code snippets we’ve provided below, and remember to create a backup before you start!

      1. Deny Access to Parts of Your Site

      One of the most useful things you can do with .htaccess is deny access to certain pages and files. There are a few files you should consider hiding in this way for security reasons, such as your wp-config.php file.

      You can do this by adding the following code, which will cause a 404 error to appear if anybody attempts to view the file:

      <Files ~ "/wp-config.php">
      Order Allow,Deny
      Deny from All
      </Files>

      In cases where sensitive data should be hidden, it can be useful to restrict access to the corresponding directory. Since many WordPress sites use the same folder structure, this setup can leave your site vulnerable. If you add the following line, it will disable the default directory listing functionality:

      Options -Indexes

      This will stop users and robots from viewing your folder structure. If anybody tries to access it, they’ll be shown a 403 error page instead.

      2. Redirect and Rewrite URLs

      Creating redirects enables you to automatically send users to a specific page. Redirects can be particularly useful if a page has moved or been deleted, and you want users who attempt to access that page to be taken somewhere else.

      You can accomplish this with a plugin such as Redirection, but it’s also possible to do it by editing the .htaccess file. To create a redirect, use the following code:

      Redirect /oldfile.html http://www.example.com/newfile.html

      You can probably see what’s going on here. The first part is the path to the old file, while the second part is the URL you want visitors to be redirected to.

      Get Content Delivered Straight to Your Inbox

      Subscribe to our blog and receive great content just like this delivered straight to your inbox.

      3. Force Your Site to Load Securely With HTTPS

      <style>.embed-container { position: relative; padding-bottom: 56.25%; height: 0; overflow: hidden; max-width: 100%; } .embed-container iframe, .embed-container object, .embed-container embed { position: absolute; top: 0; left: 0; width: 100%; height: 100%; }</style><div class=’embed-container’><iframe src=’https://www.youtube.com/embed/QeicRf_Ri3Y’ frameborder=’0′ allowfullscreen></iframe></div>

      If you have added an SSL certificate to your domain, such as DreamHost’s free Let’s Encrypt certificate, it’s a good idea to force your site to load using HTTPS. This will ensure that your site is safer for both you and your visitors.

      You can make it happen by adding the following code:

      RewriteEngine On
      RewriteCond %{HTTPS} !=on
      RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

      Your site will now automatically redirect any HTTP requests and direct them to use HTTPS instead. For example, if a user tries to access http://www.example.com, they will be automatically redirected to https://www.example.com.

      4. Change Caching Settings

      Browser caching is a process where certain website files are temporarily saved on a visitor’s local device to enable pages to load faster. Using .htaccess, you can change the amount of time that your files are stored in the browser cache until they are updated with new versions.

      There are a few different ways to do this, but for this example, we’ll use a function called mod_headers. The following code will change the maximum caching time for all jpg, jpeg, png, and gif files:

      <ifModule mod_headers.c>
      <filesMatch "\\.(jpg|jpeg|png|gif)$">
      Header set Cache-Control "max-age=2592000, public"
      </filesMatch>

      We’ve set the maximum time to 2,592,000 seconds, which equates to 30 days. You can change this amount if you want, as well as the file extensions that will be affected. If you want to add different settings for different extensions, simply add more mod_header functions.

      5. Prevent Certain Script Injection Attacks

      Script injection (or ‘code injection’) attacks attempt to change how a site or application executes by adding invalid code. For example, someone might add a script to a text field on your site and then submit it, which could cause your site to actually run the script.

      You can add the following code to protect against certain types of script injection:

      Options +FollowSymLinks
      RewriteEngine On
      RewriteCond %{QUERY_STRING} (\<|%3C).*script.*(\>|%3E) [NC,OR]
      RewriteCond %{QUERY_STRING} GLOBALS(=|\[|\%[0-9A-Z]{0,2}) [OR]
      RewriteCond %{QUERY_STRING} _REQUEST(=|\[|\%[0-9A-Z]{0,2})
      RewriteRule ^(.*)$ index.php [F,L]

      Your site should now be able to detect and stop script injection attempts and redirect the culprit to your index.php page.

      However, it’s important to note that this example will not protect against all types of injection attacks. While this particular code can certainly be useful, you should not use it as your only protection against this type of attack.

      6. Stop Username Enumeration Attacks

      Username enumeration is a process where usernames from your site are harvested by looking at each user’s author page. This is particularly problematic if someone manages to find your admin username, which makes it much easier for bots to gain access to your site.

      You can help prevent username enumeration by adding the following code:

      RewriteCond %{REQUEST_URI} !^/wp-admin [NC]
      RewriteCond %{QUERY_STRING} author=\d
      RewriteRule .* - [R=403,L]

      This will stop certain attempts to enumerate usernames and throw up a 403 error page instead. Bear in mind that this will not prevent all enumeration, and you should test your security thoroughly. We also recommend strengthening your login page further by implementing Multifactor Authentication.

      7. Prevent Image Hotlinking

      Image hotlinking is a common problem that happens when images on your server are being displayed on another site. You can stop this by adding the following code to .htaccess:

      RewriteEngine On
      RewriteCond %{HTTP_REFERER} !^$
      RewriteCond %{HTTP_REFERER} !^https://(www\.)?example.com/.*$ [NC]
      RewriteRule \.(png|gif|jpg|jpeg)$ https://xpresservers.com/wp-content/webpc-passthru.php?src=https://www.example.com/wp-content/uploads/hotlink.gif&nocache=1 [R,L]

      Replace example.com with your own domain, and this code will prevent images from loading on all other sites. Instead, the picture you specify on the last line will load. You can use this to send an alternative image to sites that try to display graphics from your server.

      Beware that this may cause issues when you might want images to appear externally, such as on search engines. You might also consider linking to a script instead of a static image, then respond with a watermarked image or an image containing an ad.

      8. Control Your File Extensions

      By using .htaccess, you can control how files of different extensions are loaded by your site. There’s a lot you can do with this feature, such as running files as PHP, but we’re just going to look at a basic example for now.

      The following code will remove the file extension from PHP files when they’re loaded. You can use this with any file type, as long as you replace all instances of “php” with the extension you want:

      RewriteEngine On
      RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /.*index\ HTTP/
      RewriteRule ^(.*)index$ http://example.com/$1 [L,R=301]
      RewriteCond %{REQUEST_FILENAME} !-d
      RewriteRule ^([^/]+)/$ http://example.com/$1 [L,R=301]
      RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /(.+)\.php\ HTTP/
      RewriteRule ^(.+)\.php$ http://example.com/$1 [L,R=301]
      RewriteRule ^([a-z]+)$ /$1.php [L]

      This will cause all PHP files to load without displaying their extension in the URL. For example, the index.php file will appear as just index.

      9. Force Files to Download

      Finally, when a file is requested on your site, the default behavior is to display it in the browser. For example, if you’re hosting an audio file, it will start to play in the browser rather than being saved to the visitor’s computer.

      You can change this by forcing the site to download the file instead. This can be done with the following code:

      AddType application/octet-stream mp3

      In this example, we’ve used mp3 files, but you can use the same function for txt, mov, or any other relevant extension.

      Improve Your Site’s Security and Performance

      The .htaccess file provides flexibility for controlling how your web server behaves. You can also use it to increase your site’s performance and get more control over exactly who can access what information.

      With .htaccess, you can deny access to particular parts of your website. Additionally, it allows you to redirect URLs, force your site to load over HTTPS, and prevent some script injection attacks.

      Editing your .htaccess file is just one way to improve your site’s security. Choosing a secure WordPress hosting provider is another. Check out our DreamPress managed hosting plans to see how we can boost your website’s security and performance!

      Do More with DreamPress

      DreamPress Plus and Pro users get access to Jetpack Professional (and 200+ premium themes) at no added cost!

      Managed WordPress Hosting - DreamPress



      Source link

      How to Develop Your Own WordPress Theme (Beginner’s Guide)


      If you want something done a certain way — well, you just might have to do it yourself. Sure, while there are plenty of great WordPress themes available, finding one that meets your specific requirements may prove difficult for some. To solve for this, you might be tempted to create your own custom WordPress theme.

      Fortunately, creating a custom theme for WordPress is a relatively straightforward process. Surprisingly, it doesn’t require a ton of technical knowledge or experience with web development. Plus, building your own theme can be well worth the effort since you can get your site looking exactly the way you want it.

      An Introduction to WordPress Theme Development

      You want your site to look great and have all the functionality you need, so you check out the WordPress Theme Directory:

      WordPress theme directory

      Unfortunately, nothing you see fulfills your requirements, and you don’t want to compromise on your vision. Maybe you want something unique that will make your site stand out, but you don’t want to spend the money on a premium theme.

      At this point, you might consider creating your own theme. Fortunately, developing a theme for WordPress is not as complicated as you might think. Thanks to the platform’s user-friendly interface and the numerous tools available, almost anyone can create a custom theme.

      We’re going to take you through the process of creating your first theme. To get started, you’ll need two things:

      You’ll also benefit from having experience with local staging environments, as you’ll be using one to create your theme. Having some understanding of CSS and PHP will also be helpful (if not necessary).

      Finally, there’s one important tool you’ll want to have, which will make the process much easier: a starter theme.

      What a Starter Theme Is (And Why You Should Use One)

      A starter theme is a bare-bones WordPress theme that you can use as a basis to create your own. This enables you to build on a solid framework without having to worry about the complexities involved in coding a theme from scratch. It will also help you understand how WordPress works by showing you the basic structure of a theme and how all its parts work together.

      There are plenty of excellent starter themes out there, including Underscores, UnderStrap, and Bones (just to name a few).

      We’ll be using Underscores for our tutorial. It’s a solid choice for beginners because it only contains the basics. Plus, this starter theme is developed by Automattic (the team behind WordPress.com), which means it’s more likely to be safe, compatible, and well-supported in the long run.

      How to Develop Your First WordPress Theme (In 5 Steps)

      With the preparation out of the way, you’re finally ready to start creating your first theme. As we mentioned earlier, we’ll be using a starter theme for this walkthrough.

      However, if you want to try creating everything yourself with no template, you should feel free to do so. Bear in mind that this approach will require a lot more coding proficiency.

      Step 1: Set Up a Local Environment

      The first thing you’ll need to do is to create a local development environment. This is effectively a server that you install on your computer, which you can use to develop and manage local WordPress sites. A local site is a safe way to develop a theme without impacting your live site in any way.

      There are many ways you can create a local environment, but we’ll be using Local.This is a fast, easy way to install a local version of WordPress for free and is compatible with both Mac and Windows:

      Local WordPress development tool

      To get started, select the free version of Local, choose your platform, add your details, and download the installer.  When the installation has been completed, you can open the program on your computer.

      Here, you’ll be asked to configure your new local environment:

      WordPress initial setup screen

      This is a straightforward process, and you’ll have your local WordPress site ready in a few minutes. Once set up, your new site will look and work exactly like a live WordPress website.

      Step 2: Download and Install Your Starter Theme

      Like most starter themes, Underscores is very easy to get started with. In fact, all you need to do is go to the website and name your theme:

      Underscores custom WordPress theme development

      If you want, you can click on Advanced Options to customize the base theme further:

      Underscores custom WordPress theme development

      Here you can fill out more information, such as the author’s name, and give the theme a description:

      Underscores custom WordPress theme development

      There’s also the _sassify! option, which will add Syntactically Awesome StyleSheets (SASS) files to your theme. SASS is a preprocessing language for CSS, which enables you to use variables, nesting, math operators, and more.

      When you’ve made your choices, you can click on Generate, which will download a .zip file containing your starter theme. This is the core file around which you’ll develop your own theme, so you’ll need to install it on your local site.

      Once you’ve installed your theme, you can preview your site to see how it looks. It’s very basic right now, but that won’t be the case for long!

      Step 3: Learn about the different components of a WordPress theme

      Before you can customize your theme, you’ll need to understand the purpose of its components and how they fit together.

      First, let’s discuss template files, which are the main building blocks of a WordPress theme. These files determine the layout and look of the content on your site.

      For example, header.php is used to create a header, while comments.php enables you to display comments.

      WordPress determines which template files to use on each page by going through the template hierarchy. This is the order in which WordPress will look for the matching template files every time a page on your site is loaded.

      For example, if you visit the URL http://example.com/post/this-post, WordPress will look for the following templates files in this order:

      1. Files that match the slug, such as this-post
      2. Files that match the post ID
      3. A generic single post file, such as single.php
      4. An archive file, such as archive.php
      5. The index.php file

      Since the index.php file is required by all themes, it’s the default option if no other file can be found. Underscores contains the most common template files and they will work right out of the box. However, you can experiment with editing them if you want to get a feel for how they work together.

      Another important element you need to grasp is The Loop. WordPress uses this code to display content, so in many ways, it’s the beating heart of your site. It appears in all template files that display post content, such as index.php or sidebar.php.

      The Loop is a complex subject that we recommend you read more about if you want to understand how WordPress displays post content. Fortunately, the Loop will already be integrated into your theme thanks to Underscores, so there’s no need to worry about it for now.

      Get Content Delivered Straight to Your Inbox

      Subscribe to our blog and receive great content just like this delivered straight to your inbox.

      Step 4: Configure Your Theme

      It’s easy to think that themes are purely for cosmetic purposes, but they actually have a huge impact on your site’s functionality. Let’s look at how you can make a few basic customizations.

      Add Functionality with ‘Hooks’

      Hooks are code snippets inserted into template files, which enable you to run PHP actions on different areas of a site, insert styling, and display other information. Most hooks are implemented directly into the WordPress core software, but some are useful for theme developers as well.

      Let’s take a look at some of the most common hooks and what they can be used for:

      • wp_head() — Added to the <head> element in header.php. It enables styles, scripts, and other information that runs as soon as the site loads.
      • wp_footer() — Added to footer.php right before the </body> tag. This is often used to insert Google Analytics code.
      • wp_meta() — This usually appears in sidebar.php to include additional scripts (such as a tag cloud).
      • comment_form() — Added to comments.php directly before the file’s closing </div> tag to display comment data.

      These hooks will already be included in your Underscores theme. However, we still recommend visiting the Hooks Database to see all available hooks and learn more about them.

      Add Styles with CSS

      Cascading Style Sheets (CSS) define the appearance of all content on your site. In WordPress, this is accomplished using the style.css file. You’ll already have this file included in your theme, but at the moment, it only contains the basic, default styling:

      editing the CSS stylesheet of a new custom WordPress theme

      If you want a quick example of how CSS works, you can edit any of the styles here and save the file to see the effects. For example, you can find the following code (usually on line 485):

      a {
      color: royalblue;
      }

      This code controls the color of unvisited hyperlinks, which appear royal blue by default:

      WordPress custom theme test site

      Let’s see what happens if we try to change that by replacing it with the following code:

      a {
      color: red;
      }

      Save the file and check out your local site. As you might expect, all unvisited links will now appear bright red:

      sample page of a test custom WordPress theme

      You might notice that the visited link at the top has not changed color. That’s because it’s actually governed by the next section in the stylesheet:

      a:visited {
      color: purple;
      }

      This is a very basic example of how editing style.css will affect the look of your site. CSS is a massive topic that we recommend you explore further if you want to learn more about creating web designs. There are plenty of resources on the topic for beginners.

      Step 5: Export the Theme and Upload It to Your Site

      When you’ve finished tinkering with your theme, it’s time to make sure it works properly. To do this, you can use the Theme Unit Test data.

      This is a set of dummy data that you can upload to your site. It contains many different variations of styles and content, and it will enable you to see how your theme copes with unpredictable data.

      When you’ve thoroughly tested your theme and are convinced that it meets the required standards, all that remains now is to export it.

      First, you’ll need to find the location of your website on your local machine. You’ll likely find it in a folder called Websites, inside your default Documents directory.

      Open the website’s folder and access /wp-content/themes/, where you’ll find your theme:

      WordPress wp-content themes folder in FTP client

      You can now use a compression tool, such as WinRAR, to create a .zip file based on the folder. Simply right-click on the folder and select the option that enables you to zip it, such as Compress “folder”:

      compressing custom WordPress theme to prepare for upload

      When the folder has been zipped, it’s ready to be uploaded and installed on any WordPress site, just as you installed your Underscores theme at the start. If you’re particularly happy with the result, you could even submit your theme to the WordPress Theme Directory!

      Create a Custom WordPress Theme

      Creating a custom WordPress theme from scratch is no small feat. However, the process might not be as difficult as you might think.

      To recap, here’s how to develop a WordPress theme in five simple steps:

      1. Set up a local environment, using Local.
      2. Download and install a starter theme, like Underscores.
      3. Learn about the different components of a WordPress theme.
      4. Configure your theme.
      5. Export the theme and upload it to your site.

      By following the guidelines in the Codex documentation site, you can develop a theme that meets quality standards. You might even consider submitting it to the WordPress Theme Directory!

      Do More with DreamPress

      DreamPress Plus and Pro users get access to Jetpack Professional (and 200+ premium themes) at no added cost!

      Managed WordPress Hosting - DreamPress



      Source link

      The Beginner’s Guide to WordPress 404 Error Pages


      The content you post on your website — whether part of a page or post — is usually permanent. However, if an issue arises (either technical or otherwise), an item of content may not display. Instead, it triggers a 404 error, which isn’t good news for your website or its users.

      In a nutshell, a 404 error signifies that a web page is not found. However, unlike other errors, they’re usually displayed on dedicated pages. With a customized and optimized 404 error page, you can get visitors back on the right track.

      What is a 404 Error?

      Airbnb 404 error page example

      As we discussed, a 404 error is a response code indicating that although a user was able to connect to a website’s server, the page can’t be found. This occurs for a number of reasons, such as:

      • A page or post has been moved or deleted.
      • The server is having trouble loading the page.
      • The URL that leads to the page is incorrect.
      • The post or page never existed in the first place.

      Naturally, a 404 error can significantly reduce your website’s traffic. As such, it’s crucial that you find and fix these errors on your website fast. First, however, let’s look at what 404 error pages are used for.

      An Introduction to 404 Error Pages

      A 404 error page alerts visitors to a missing page or incorrect URL. Many websites use the default page provided by their theme, but 404 error pages can also be customized to improve User Experience (UX).

      Most commonly, an error page will note the issue and provide alternative options for the user to choose from: for example, a Return to the Home Page link, related content, or a Search box.

      A good 404 error page should contain a few essential elements. These include a link or navigation menu, an on-brand apology or explanation, and a Search box.

      For example, Cloud Sigma opted for a quirky explanation and an easy-to-find Back to Homepage button. This helps to lessen the frustration while also enabling the user to return to the main site with minimal interruption:

      404 error page example

      Repair Pal presents another good example of a well-implemented 404 error page. They opted to stick with their default theme — keeping the navigation menu intact — while also providing users with a way to interact immediately with the page.

      For example, visitors can choose to Get an Estimate or Troubleshoot Your Car:

      404 error page example

      As you can see, creating a functional page is a useful way of mitigating the effects of a 404 error. It can also ensure that your website has an air of professionalism, despite an error being present.

      Get Content Delivered Straight to Your Inbox

      Subscribe to our blog and receive great content just like this delivered straight to your inbox.

      How to Find and Fix 404 Errors on Your WordPress Website

      While 404 errors are bound to happen on occasion, frequent occurrences can mean more serious problems are present. For example, there could be issues with your website’s server or with incorrectly set permalinks.

      Fortunately, it’s possible to find these errors within WordPress. What’s more, once the issues are resolved, you can apply what you’ve learned to avoid the problem occurring in the future.

      How to Create a 404 Errors Report in GA4

      Google Analytics is great for rooting out 404 errors. Within the dashboard, go to Explore and choose Blank:

      Google Analytics 4 404 error report

      Name your report “404 Report” and click on the + sign next to Dimensions:

      Google Analytics 4 404 error report

      Select Page title and Page path + query string from the available dimensions and click on Import. Next, click on the + sign next to Metrics to find and import Sessions:

      Google Analytics 4 404 error report

      You’ll now need to drag your Dimensions under Rows and Metrics under Values:

      Google Analytics 4 404 error report

      Next, drag Page title under Filter. Then, choose contains from the dropdown menu and type “Page not found” into the Enter expression box:

      Google Analytics 4 404 error report

      Hit Apply, and you’ll see a report of all the 404 errors on your website. Regardless of whether there’s a wider problem on your site, WordPress makes this easy to fix.

      How to Deal With 404 Errors On Your Website

      Even if you do your best to avoid them, 404 errors are bound to happen from time to time. However, there are ways to minimize their disruption. Let’s take a look at two now.

      1. Create a Dedicated 404 Error Page

      404 error page example

      WordPress is flexible enough to let you edit practically all of your 404 error page’s elements. To create a custom 404 error page for your site, you have two options — manually or using plugins.

      Many themes include a 404.php template file by default. If this is the case for your theme, you can locate the file yourself and edit the message that’s currently in place.

      Before you do that, however, it’s a good idea to create a child theme to work with. That way, you won’t be making permanent changes to the parent theme.

      After creating a child theme, go to Appearance > Editor within WordPress and open 404.php in the file list to the right of the editor:

      WordPress 404 error page template file

      From here, look for the <div class=”page content”> line, and simply edit the message to your own requirements (saving your changes once you’re done).

      Note that if you’re using a WordPress block theme, you can edit its 404 page by navigating to Appearance > Editor > Templates:

      WordPress template editor

      Simply click on 404, and you’ll be taken to an editing screen where you can build a custom 404 page using WordPress blocks and template parts:

      404 error page example

      If you don’t have a 404.php file in your current theme, you can create your own using the guidelines found in the WordPress Codex. However, you’ll need access to an FTP client such as FileZilla.

      Open FileZilla, and enter your website credentials to gain access to your file directory. Double-click your website’s root folder (sometimes called public_html), and navigate to wp-content > themes > [themename] > 404.php. We’re using Twenty Thirteen’s 404 template, but you’re welcome to browse to another theme with a similar template.

      Next, right-click the 404.php file and select View/Edit:

      edit 404.php file via FTP client

      The file will open in your text editor. Highlight the entire code within, and copy it. Now return to FileZilla and navigate back to the themes directory. Select your current website theme and right-click. Select Create new file from the drop-down, and name it “404.php”.

      Click OK, then right-click the new 404.php file. Select View/Edit from the drop-down and paste the code that you previously copied. Of course, you can edit the content to your own requirements. Once you save the file, you’re all set!

      create a 404 error php file

      Alternatively, you can use WordPress plugins such as 404page and Custom 404 Pro to achieve the same goal. Once installed, they enable you to replace your theme’s default 404 page or create one if your theme doesn’t have one included. These plugins will be ideal if you’re wary about tinkering with your WordPress core file structure.

      2. Set Up an Automatic Redirect to a More Useful Page

      No More 404 Errors WordPress plugin

      An alternative to a 404 error page is to just redirect the visitor. Simply put, a page redirect is a way to send traffic from one web page (such as a 404 error page) to another. This is a good choice for a number of reasons.

      For example, if you’ve changed the URL of an old page or post or deleted any old content, you can redirect visitors to the new page. The good news is that there are a plethora of redirect plugins available, including Redirection and Safe Redirect Manager.

      Set Up a 404 Error Page on Your WordPress Site Today

      404 errors require a quick and professional response in order to prevent your website’s traffic from being negatively affected. Fortunately, WordPress makes it easy to manage 404 errors and redirect visitors.

      Do More with DreamPress

      DreamPress Plus and Pro users get access to Jetpack Professional (and 200+ premium themes) at no added cost!

      Managed WordPress Hosting - DreamPress



      Source link